instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
Show team id vs acc_percent as scatter plot use a different color for each ACC_Road
CREATE TABLE basketball_match (Team_ID int,School_ID int,Team_Name text,ACC_Regular_Season text,ACC_Percent text,ACC_Home text,ACC_Road text,All_Games text,All_Games_Percent int,All_Home text,All_Road text,All_Neutral text)CREATE TABLE university (School_ID int,School text,Location text,Founded real,Affiliation text,En...
SELECT Team_ID, ACC_Percent FROM basketball_match GROUP BY ACC_Road
When the entrant is fred saunders what is the driver?
CREATE TABLE table_62893 ("Driver" text,"Entrant" text,"Constructor" text,"Time/Retired" text,"Grid" real)
SELECT "Driver" FROM table_62893 WHERE "Entrant" = 'fred saunders'
Questions with exactly 1 Tag.
CREATE TABLE PostHistory (Id number,PostHistoryTypeId number,PostId number,RevisionGUID other,CreationDate time,UserId number,UserDisplayName text,Comment text,Text text,ContentLicense text)CREATE TABLE ReviewTasks (Id number,ReviewTaskTypeId number,CreationDate time,DeletionDate time,ReviewTaskStateId number,PostId nu...
SELECT pt.PostId AS "post_link", t.TagName FROM PostTags AS pt LEFT JOIN Tags AS t ON t.Id = pt.TagId WHERE EXISTS(SELECT 1 FROM PostTags AS pt2 WHERE pt2.PostId = pt.PostId GROUP BY pt2.PostId HAVING COUNT(pt2.TagId) = 1) LIMIT 50
Which finish has 33 as a rank and 200 for laps?
CREATE TABLE table_name_24 (finish VARCHAR,rank VARCHAR,laps VARCHAR)
SELECT finish FROM table_name_24 WHERE rank = "33" AND laps = 200
What Club has 13 wins, goals against less than 48, and a position of 4?
CREATE TABLE table_60869 ("Position" real,"Club" text,"Played" real,"Points" real,"Wins" real,"Draws" real,"Losses" real,"Goals for" real,"Goals against" real,"Goal Difference" real)
SELECT "Club" FROM table_60869 WHERE "Wins" = '13' AND "Goals against" < '48' AND "Position" = '4'
Which Length has a Country of soviet union, and a Year larger than 1975?
CREATE TABLE table_name_52 (length VARCHAR,country VARCHAR,year VARCHAR)
SELECT length FROM table_name_52 WHERE country = "soviet union" AND year > 1975
RPG.SE Beta Users Still Active In Last Month.
CREATE TABLE SuggestedEditVotes (Id number,SuggestedEditId number,UserId number,VoteTypeId number,CreationDate time,TargetUserId number,TargetRepChange number)CREATE TABLE PostHistoryTypes (Id number,Name text)CREATE TABLE ReviewRejectionReasons (Id number,Name text,Description text,PostTypeId number)CREATE TABLE Posts...
SELECT DisplayName, Reputation FROM Users WHERE CreationDate < '2012/04/11' AND LastAccessDate > DATEADD(m, -1, GETDATE()) ORDER BY Reputation DESC
when did patient 13528 visit the hospital via transfer from skilled nur, the last time since 2104?
CREATE TABLE inputevents_cv (row_id number,subject_id number,hadm_id number,icustay_id number,charttime time,itemid number,amount number)CREATE TABLE diagnoses_icd (row_id number,subject_id number,hadm_id number,icd9_code text,charttime time)CREATE TABLE cost (row_id number,subject_id number,hadm_id number,event_type t...
SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 13528 AND admissions.admission_location = 'transfer from skilled nur' AND STRFTIME('%y', admissions.admittime) >= '2104' ORDER BY admissions.admittime DESC LIMIT 1
What were the total number of sales for the song 21 Seconds?
CREATE TABLE table_14994 ("Position" real,"Song Title" text,"Artist" text,"Highest Position" real,"Sales" real)
SELECT COUNT("Sales") FROM table_14994 WHERE "Song Title" = '21 seconds'
What Position has a Player named kenneth udjus?
CREATE TABLE table_name_47 (position VARCHAR,player VARCHAR)
SELECT position FROM table_name_47 WHERE player = "kenneth udjus"
What is the minimum if 40 to 44?
CREATE TABLE table_16457934_5 (Id VARCHAR)
SELECT MIN(40 AS _to_44) FROM table_16457934_5
List how many students in each last name who majored in 600 using a bar chart, and sort by the bars from low to high.
CREATE TABLE Restaurant_Type (ResTypeID INTEGER,ResTypeName VARCHAR(40),ResTypeDescription VARCHAR(100))CREATE TABLE Type_Of_Restaurant (ResID INTEGER,ResTypeID INTEGER)CREATE TABLE Student (StuID INTEGER,LName VARCHAR(12),Fname VARCHAR(12),Age INTEGER,Sex VARCHAR(1),Major INTEGER,Advisor INTEGER,city_code VARCHAR(3))C...
SELECT LName, COUNT(LName) FROM Student WHERE Major = 600 GROUP BY LName ORDER BY LName
how many patients of white ethnicity followed the procedure dx ultrasound-heart?
CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid text)CREATE TABLE demographic (subject_id text,hadm_id text,name text,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay text,insurance text,ethni...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "WHITE" AND procedures.short_title = "Dx ultrasound-heart"
What kind of League has a Venue of billesley common?
CREATE TABLE table_name_48 (league VARCHAR,venue VARCHAR)
SELECT league FROM table_name_48 WHERE venue = "billesley common"
Return a bar chart on what are the apartment number and the room count of each apartment?, and rank in ascending by the y axis.
CREATE TABLE Apartment_Facilities (apt_id INTEGER,facility_code CHAR(15))CREATE TABLE View_Unit_Status (apt_id INTEGER,apt_booking_id INTEGER,status_date DATETIME,available_yn BIT)CREATE TABLE Apartments (apt_id INTEGER,building_id INTEGER,apt_type_code CHAR(15),apt_number CHAR(10),bathroom_count INTEGER,bedroom_count ...
SELECT apt_number, room_count FROM Apartments ORDER BY room_count
What is the catalog of the release from January 23, 2002?
CREATE TABLE table_80340 ("Region" text,"Date" text,"Label" text,"Format" text,"Catalog" text)
SELECT "Catalog" FROM table_80340 WHERE "Date" = 'january 23, 2002'
What is Application Sharing, when Web Conferencing is 'Web Conferencing'?
CREATE TABLE table_59590 ("Name" text,"E-mail server" text,"Faxing" text,"Instant messaging" text,"Telephony" text,"Videoconferencing" text,"Web conferencing" text,"Data conferencing" text,"Application sharing" text,"Electronic meeting system" text,"Synchronous conferencing" text)
SELECT "Application sharing" FROM table_59590 WHERE "Web conferencing" = 'web conferencing'
How many teams have 7th position?
CREATE TABLE table_22056184_1 (team VARCHAR,position VARCHAR)
SELECT COUNT(team) FROM table_22056184_1 WHERE position = "7th"
How many values for a win by 2 or more goals correspond to a difference of 2, more than 9 points, and the America-RJ team when more than 7 are played?
CREATE TABLE table_35490 ("Position" real,"Team" text,"Points" real,"Played" real,"Won by 2 or more goals difference" real,"Drawn" real,"Lost" real,"Against" real,"Difference" text)
SELECT COUNT("Won by 2 or more goals difference") FROM table_35490 WHERE "Difference" = '2' AND "Points" > '9' AND "Team" = 'america-rj' AND "Played" > '7'
Top StackOverflow users in Singapore.
CREATE TABLE PostHistoryTypes (Id number,Name text)CREATE TABLE Badges (Id number,UserId number,Name text,Date time,Class number,TagBased boolean)CREATE TABLE ReviewTasks (Id number,ReviewTaskTypeId number,CreationDate time,DeletionDate time,ReviewTaskStateId number,PostId number,SuggestedEditId number,CompletedByRevie...
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation FROM Users WHERE (LOWER(Location) LIKE '%singapore%' OR LOWER(Location) LIKE '%singapore%') AND Reputation >= 10000 ORDER BY Reputation DESC
How many accounts for each customer? Show a bar chart that groups by customer's first name, could you order in ascending by the X?
CREATE TABLE Order_Items (order_item_id INTEGER,order_id INTEGER,product_id INTEGER,product_quantity VARCHAR(50),other_order_item_details VARCHAR(255))CREATE TABLE Product_Categories (production_type_code VARCHAR(15),product_type_description VARCHAR(80),vat_rating DECIMAL(19,4))CREATE TABLE Customers (customer_id INTEG...
SELECT customer_first_name, COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY customer_first_name
What is the total number of bronzes associated with 1 silver, ranks under 6 and under 6 golds?
CREATE TABLE table_76002 ("Rank" real,"Republic" text,"Gold" real,"Silver" real,"Bronze" real,"Total" real)
SELECT SUM("Bronze") FROM table_76002 WHERE "Silver" = '1' AND "Rank" < '6' AND "Gold" < '6'
Top 10 stackoverflow users from Himachal.
CREATE TABLE CloseAsOffTopicReasonTypes (Id number,IsUniversal boolean,InputTitle text,MarkdownInputGuidance text,MarkdownPostOwnerGuidance text,MarkdownPrivilegedUserGuidance text,MarkdownConcensusDescription text,CreationDate time,CreationModeratorId number,ApprovalDate time,ApprovalModeratorId number,DeactivationDat...
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation, Location FROM Users WHERE LOWER(Location) LIKE '%himachal%' OR UPPER(Location) LIKE '%HIMACHAL%' OR Location LIKE '%Himachal%' AND Reputation >= 10000 ORDER BY Reputation DESC LIMIT 10
what is the number of patients whose year of birth is less than 2101 and procedure long title is closed biopsy of skin and subcutaneous tissue?
CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid text)CREATE TABLE prescriptions (subject_id text,hadm_id text,icustay_id text,drug_type text,drug text,formulary_drug_cd text,route text,drug_dose text)CREATE TABLE demographic (subject_id text,hadm_id t...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2101" AND procedures.long_title = "Closed biopsy of skin and subcutaneous tissue"
which area has a rank of 60?
CREATE TABLE table_22916979_2 (metropolitan_area VARCHAR,rank VARCHAR)
SELECT metropolitan_area FROM table_22916979_2 WHERE rank = 60
number of wins in the season .
CREATE TABLE table_203_490 (id number,"date" text,"opponent#" text,"rank#" text,"site" text,"result" text,"attendance" number)
SELECT COUNT(*) FROM table_203_490 WHERE "result" = 'w'
What name is the goals of 25?
CREATE TABLE table_5070 ("Ranking" real,"Nationality" text,"Name" text,"Years" text,"Goals" real)
SELECT "Name" FROM table_5070 WHERE "Goals" = '25'
Name the number for margin of victory being 3 strokes
CREATE TABLE table_24381 ("No." real,"Date" text,"Tournament" text,"Winning score" text,"To par" text,"Margin of victory" text,"Runner(s)-up" text)
SELECT COUNT("No.") FROM table_24381 WHERE "Margin of victory" = '3 strokes'
provide the number of patients whose marital status is divorced and primary disease is celo-vessicle fistula?
CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid text)CREATE TABLE demographic (subject_id text,hadm_id text,name text,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay text,insurance text,ethni...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.marital_status = "DIVORCED" AND demographic.diagnosis = "CELO-VESSICLE FISTULA"
How many status are there for Moncton?
CREATE TABLE table_176529_2 (status VARCHAR,official_name VARCHAR)
SELECT COUNT(status) FROM table_176529_2 WHERE official_name = "Moncton"
what are the event details of the services that have the type code 'Marriage', and count them by a bar chart, and show from high to low by the bars.
CREATE TABLE Participants_in_Events (Event_ID INTEGER,Participant_ID INTEGER)CREATE TABLE Services (Service_ID INTEGER,Service_Type_Code CHAR(15))CREATE TABLE Participants (Participant_ID INTEGER,Participant_Type_Code CHAR(15),Participant_Details VARCHAR(255))CREATE TABLE Events (Event_ID INTEGER,Service_ID INTEGER,Eve...
SELECT Event_Details, COUNT(Event_Details) FROM Events AS T1 JOIN Services AS T2 ON T1.Service_ID = T2.Service_ID WHERE T2.Service_Type_Code = 'Marriage' GROUP BY Event_Details ORDER BY Event_Details DESC
what number of male patients had bone marrow transplant?
CREATE TABLE diagnoses (subject_id text,hadm_id text,icd9_code text,short_title text,long_title text)CREATE TABLE prescriptions (subject_id text,hadm_id text,icustay_id text,drug_type text,drug text,formulary_drug_cd text,route text,drug_dose text)CREATE TABLE procedures (subject_id text,hadm_id text,icd9_code text,sho...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.gender = "M" AND diagnoses.long_title = "Bone marrow replaced by transplant"
tell me the number of patients who were ordered platelet count lab test and had abnormal lab test status.
CREATE TABLE procedures (subject_id text,hadm_id text,icd9_code text,short_title text,long_title text)CREATE TABLE prescriptions (subject_id text,hadm_id text,icustay_id text,drug_type text,drug text,formulary_drug_cd text,route text,drug_dose text)CREATE TABLE diagnoses (subject_id text,hadm_id text,icd9_code text,sho...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE lab.flag = "abnormal" AND lab.label = "Platelet Count"
How many home losses occured when PF 13?
CREATE TABLE table_922 ("Num" real,"Team" text,"W" real,"L" real,"PCT" text,"PF" real,"PA" real,"Last appearance" real,"Last championship" text,"HOME games" real,"Home wins" real,"Home losses" real,"Home Win Pct." text,"ROAD games" real,"Road wins" real,"Road losses" real,"Road Win Pct." text)
SELECT COUNT("Home losses") FROM table_922 WHERE "PF" = '13'
What's the name of the barangay whose area is 3.6787 km ?
CREATE TABLE table_2004733_2 (barangay VARCHAR,area__in_km_2__ VARCHAR)
SELECT barangay FROM table_2004733_2 WHERE area__in_km_2__ = "3.6787"
What is the lowest total medals for the united states who had more than 11 silver medals?
CREATE TABLE table_name_80 (total INTEGER,country VARCHAR,silver VARCHAR)
SELECT MIN(total) FROM table_name_80 WHERE country = "united states" AND silver > 11
aged 20 _ 30 or 60 _ 70
CREATE TABLE table_train_110 ("id" int,"cholesterol" float,"body_weight" float,"creatinine_clearance_cl" float,"triglyceride_tg" float,"age" float,"NOUSE" float)
SELECT * FROM table_train_110 WHERE (age >= 20 AND age <= 30) OR (age >= 60 OR age <= 70)
For all employees who have the letters D or S in their first name, give me the comparison about the average of manager_id over the job_id , and group by attribute job_id, and rank bar from low to high order.
CREATE TABLE jobs (JOB_ID varchar(10),JOB_TITLE varchar(35),MIN_SALARY decimal(6,0),MAX_SALARY decimal(6,0))CREATE TABLE countries (COUNTRY_ID varchar(2),COUNTRY_NAME varchar(40),REGION_ID decimal(10,0))CREATE TABLE locations (LOCATION_ID decimal(4,0),STREET_ADDRESS varchar(40),POSTAL_CODE varchar(12),CITY varchar(30),...
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY JOB_ID
Who had the most assists in the game that led to a 3-7 record?
CREATE TABLE table_76865 ("Game" real,"Date" text,"Opponent" text,"Score" text,"High points" text,"High rebounds" text,"High assists" text,"Location/Attendance" text,"Record" text)
SELECT "High assists" FROM table_76865 WHERE "Record" = '3-7'
Draw a bar chart for what are the department names and how many employees work in each of them?, sort the total number from low to high order.
CREATE TABLE job_history (EMPLOYEE_ID decimal(6,0),START_DATE date,END_DATE date,JOB_ID varchar(10),DEPARTMENT_ID decimal(4,0))CREATE TABLE employees (EMPLOYEE_ID decimal(6,0),FIRST_NAME varchar(20),LAST_NAME varchar(25),EMAIL varchar(25),PHONE_NUMBER varchar(20),HIRE_DATE date,JOB_ID varchar(10),SALARY decimal(8,2),CO...
SELECT DEPARTMENT_NAME, COUNT(*) FROM employees AS T1 JOIN departments AS T2 ON T1.DEPARTMENT_ID = T2.DEPARTMENT_ID GROUP BY DEPARTMENT_NAME ORDER BY COUNT(*)
What is the unemployment rate in those places in Alexander county whose status is transitional?
CREATE TABLE table_2709 ("County" text,"Population" real,"Unemployment Rate" text,"Market Income Per Capita" text,"Poverty Rate" text,"Status" text)
SELECT "Unemployment Rate" FROM table_2709 WHERE "Status" = 'Transitional' AND "County" = 'Alexander'
Name the total number directed by for uk viewers being 6.86
CREATE TABLE table_18012738_1 (directed_by VARCHAR,uk_viewers__million_ VARCHAR)
SELECT COUNT(directed_by) FROM table_18012738_1 WHERE uk_viewers__million_ = "6.86"
What distance did the winning horse run in the Summer Doldrums.
CREATE TABLE table_58023 ("Date" text,"Track" text,"Race" text,"Distance" text,"Surface track" text,"Winning horse" text,"Winning jockey" text)
SELECT "Distance" FROM table_58023 WHERE "Winning horse" = 'summer doldrums'
what is the type when the year(s) is 1982?
CREATE TABLE table_name_23 (type VARCHAR,year_s_ VARCHAR)
SELECT type FROM table_name_23 WHERE year_s_ = "1982"
what is the number of goals d m szalai made against san marino in 2010 ?
CREATE TABLE table_203_551 (id number,"goal" number,"date" text,"venue" text,"opponent" text,"score" text,"result" text,"competition" text)
SELECT COUNT(*) FROM table_203_551 WHERE "opponent" = 'san marino' AND "date" = 2010
what is the laps when the time/retired is turbo and the grid is less than 14?
CREATE TABLE table_55466 ("Driver" text,"Constructor" text,"Laps" real,"Time/Retired" text,"Grid" real)
SELECT "Laps" FROM table_55466 WHERE "Time/Retired" = 'turbo' AND "Grid" < '14'
Stats For Rep Per Post.
CREATE TABLE PostNotices (Id number,PostId number,PostNoticeTypeId number,CreationDate time,DeletionDate time,ExpiryDate time,Body text,OwnerUserId number,DeletionUserId number)CREATE TABLE PostTypes (Id number,Name text)CREATE TABLE SuggestedEditVotes (Id number,SuggestedEditId number,UserId number,VoteTypeId number,C...
WITH repPerPostUser AS (SELECT u.Id, CAST(u.Reputation AS FLOAT(15, 5)) / CAST(CASE WHEN COUNT(p.Id) = 0 THEN 1 ELSE COUNT(p.Id) END AS FLOAT(15, 5)) AS RepPerPost FROM Users AS u INNER JOIN Posts AS p ON u.Id = p.OwnerUserId GROUP BY u.Id, u.Reputation) SELECT AVG(RepPerPost) AS Mean_RepPerPost, MAX(RepPerPost) AS Max...
What team was played on november 24?
CREATE TABLE table_23211041_5 (team VARCHAR,date VARCHAR)
SELECT team FROM table_23211041_5 WHERE date = "November 24"
What is the circuit located in baltimore , maryland?
CREATE TABLE table_31518 ("Rnd" real,"Circuit" text,"Location" text,"Date" text,"Pole position" text,"Fastest lap" text,"Winning driver" text,"Winning team" text,"Supporting" text)
SELECT "Circuit" FROM table_31518 WHERE "Location" = 'Baltimore , Maryland'
What is the label for catalogue of RT-346-5?
CREATE TABLE table_32174 ("Region" text,"Date" text,"Label" text,"Format" text,"Catalogue" text)
SELECT "Label" FROM table_32174 WHERE "Catalogue" = 'rt-346-5'
which Pada 3 has a Pada 2 of che?
CREATE TABLE table_name_27 (pada_3 VARCHAR,pada_2 VARCHAR)
SELECT pada_3 FROM table_name_27 WHERE pada_2 = "चे che"
What's the 1986 if 1991 has a QF and 1998 has a 3R?
CREATE TABLE table_name_51 (Id VARCHAR)
SELECT 1986 FROM table_name_51 WHERE 1991 = "qf" AND 1998 = "3r"
Find the name of customers who do not have a loan with a type of Mortgages.
CREATE TABLE bank (branch_id number,bname text,no_of_customers number,city text,state text)CREATE TABLE customer (cust_id text,cust_name text,acc_type text,acc_bal number,no_of_loans number,credit_score number,branch_id number,state text)CREATE TABLE loan (loan_id text,loan_type text,cust_id text,branch_id text,amount ...
SELECT cust_name FROM customer EXCEPT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE T2.loan_type = 'Mortgages'
Who directed the film Nuits d'arabie?
CREATE TABLE table_22738 ("Submitting country" text,"Film title used in nomination" text,"Original title" text,"Language(s)" text,"Director(s)" text,"Result" text)
SELECT "Director(s)" FROM table_22738 WHERE "Film title used in nomination" = 'Nuits d''Arabie'
what was the first medication patient 83062 was prescribed via oral route in the current hospital encounter?
CREATE TABLE d_icd_diagnoses (row_id number,icd9_code text,short_title text,long_title text)CREATE TABLE d_items (row_id number,itemid number,label text,linksto text)CREATE TABLE inputevents_cv (row_id number,subject_id number,hadm_id number,icustay_id number,charttime time,itemid number,amount number)CREATE TABLE icus...
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83062 AND admissions.dischtime IS NULL) AND prescriptions.route = 'oral' ORDER BY prescriptions.startdate LIMIT 1
Users with most suggested edits.
CREATE TABLE ReviewTaskResultTypes (Id number,Name text,Description text)CREATE TABLE PostFeedback (Id number,PostId number,IsAnonymous boolean,VoteTypeId number,CreationDate time)CREATE TABLE SuggestedEditVotes (Id number,SuggestedEditId number,UserId number,VoteTypeId number,CreationDate time,TargetUserId number,Targ...
SELECT OwnerUserId AS "user_link", COUNT(Id) AS Total, COUNT(ApprovalDate) AS Approved, COUNT(RejectionDate) AS Rejected, ROUND((COUNT(ApprovalDate)) * 100.0 / (COUNT(Id)), 2) AS PercApproved, ROUND((COUNT(RejectionDate)) * 100.0 / (COUNT(Id)), 2) AS PercRejected FROM SuggestedEdits GROUP BY OwnerUserId ORDER BY COUNT(...
what is the last time patient 73913 had the microbiology test in the last hospital encounter?
CREATE TABLE diagnoses_icd (row_id number,subject_id number,hadm_id number,icd9_code text,charttime time)CREATE TABLE patients (row_id number,subject_id number,gender text,dob time,dod time)CREATE TABLE d_icd_diagnoses (row_id number,icd9_code text,short_title text,long_title text)CREATE TABLE inputevents_cv (row_id nu...
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73913 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY microbiologyevents.charttime DESC LIMIT 1
Top Posts with 'Application' in Feedback Section.
CREATE TABLE SuggestedEdits (Id number,PostId number,CreationDate time,ApprovalDate time,RejectionDate time,OwnerUserId number,Comment text,Text text,Title text,Tags text,RevisionGUID other)CREATE TABLE Comments (Id number,PostId number,Score number,Text text,CreationDate time,UserDisplayName text,UserId number,Content...
SELECT ParentId AS "post_link", COUNT(PostId) AS "id" FROM Posts, PostFeedback WHERE PostTypeId = 1 AND LENGTH(Body) <= 200 AND (Body LIKE '%pplicatio%') GROUP BY ParentId, PostFeedback.Id HAVING COUNT(Posts.Id) > 1 ORDER BY COUNT(Posts.Id) DESC
Draw a bar chart of affiliation versus sum enrollment, and could you rank by the names from high to low?
CREATE TABLE basketball_match (Team_ID int,School_ID int,Team_Name text,ACC_Regular_Season text,ACC_Percent text,ACC_Home text,ACC_Road text,All_Games text,All_Games_Percent int,All_Home text,All_Road text,All_Neutral text)CREATE TABLE university (School_ID int,School text,Location text,Founded real,Affiliation text,En...
SELECT Affiliation, SUM(Enrollment) FROM university GROUP BY Affiliation ORDER BY Affiliation DESC
What is the School of the quarterback?
CREATE TABLE table_34313 ("Position" text,"Name" text,"School" text,"Unanimous" text,"College Hall of Fame" text)
SELECT "School" FROM table_34313 WHERE "Position" = 'quarterback'
since 1 year ago what are the top five most frequent microbiological tests given to patients within 2 months after inject/infuse nec?
CREATE TABLE cost (row_id number,subject_id number,hadm_id number,event_type text,event_id number,chargetime time,cost number)CREATE TABLE transfers (row_id number,subject_id number,hadm_id number,icustay_id number,eventtype text,careunit text,wardid number,intime time,outtime time)CREATE TABLE d_icd_diagnoses (row_id ...
SELECT t3.spec_type_desc FROM (SELECT t2.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FR...
What was the result of week 2?
CREATE TABLE table_name_93 (result VARCHAR,week VARCHAR)
SELECT result FROM table_name_93 WHERE week = "week 2"
What is the name and city of the airport that the most routes end at?
CREATE TABLE airlines (alid number,name text,iata text,icao text,callsign text,country text,active text)CREATE TABLE airports (apid number,name text,city text,country text,x number,y number,elevation number,iata text,icao text)CREATE TABLE routes (rid number,dst_apid number,dst_ap text,src_apid number,src_ap text,alid ...
SELECT T1.name, T1.city, T2.dst_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid GROUP BY T2.dst_apid ORDER BY COUNT(*) DESC LIMIT 1
WHAT IS THE FLOOR NUMBERS WITH 01.0 10 light street?
CREATE TABLE table_name_57 (floors INTEGER,street_address VARCHAR)
SELECT SUM(floors) FROM table_name_57 WHERE street_address = "01.0 10 light street"
what is the number of patients who received a extracorporeal circulat procedure within the same month after having received a packed cell transfusion procedure during a year before?
CREATE TABLE transfers (row_id number,subject_id number,hadm_id number,icustay_id number,eventtype text,careunit text,wardid number,intime time,outtime time)CREATE TABLE icustays (row_id number,subject_id number,hadm_id number,icustay_id number,first_careunit text,last_careunit text,first_wardid number,last_wardid numb...
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'packed cell...
Bring me the number of patients with adelta abnormal lab test who were diagnosed with long-term (current) use of steroids.
CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid text)CREATE TABLE diagnoses (subject_id text,hadm_id text,icd9_code text,short_title text,long_title text)CREATE TABLE prescriptions (subject_id text,hadm_id text,icustay_id text,drug_type text,drug text...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Long-term (current) use of steroids" AND lab.flag = "delta"
Show all origins and the number of flights from each origin Show bar chart, display in desc by the y axis please.
CREATE TABLE flight (flno number(4,0),origin varchar2(20),destination varchar2(20),distance number(6,0),departure_date date,arrival_date date,price number(7,2),aid number(9,0))CREATE TABLE aircraft (aid number(9,0),name varchar2(30),distance number(6,0))CREATE TABLE employee (eid number(9,0),name varchar2(30),salary nu...
SELECT origin, COUNT(*) FROM flight GROUP BY origin ORDER BY COUNT(*) DESC
how many overall goals were scored at moses mabhida stadium?
CREATE TABLE table_29761 ("Stadium" text,"City" text,"Capacity" real,"Matches played" real,"Overall attendance" real,"Average attendance per match" real,"Average attendance as % of Capacity" text,"Overall goals scored" real,"Average goals scored per match" text,"Elevation" text)
SELECT MAX("Overall goals scored") FROM table_29761 WHERE "Stadium" = 'Moses Mabhida Stadium'
What is the average number of EVA for the Orion?
CREATE TABLE table_name_50 (number_of_s_eva INTEGER,lunar_lander VARCHAR)
SELECT AVG(number_of_s_eva) FROM table_name_50 WHERE lunar_lander = "orion"
What is the most common interaction type between enzymes and medicine? And how many are there?
CREATE TABLE medicine (id number,name text,trade_name text,fda_approved text)CREATE TABLE medicine_enzyme_interaction (enzyme_id number,medicine_id number,interaction_type text)CREATE TABLE enzyme (id number,name text,location text,product text,chromosome text,omim number,porphyria text)
SELECT interaction_type, COUNT(*) FROM medicine_enzyme_interaction GROUP BY interaction_type ORDER BY COUNT(*) DESC LIMIT 1
Which ministers are not a part of the Progress Party, and count them by a bar chart
CREATE TABLE party (Party_ID int,Minister text,Took_office text,Left_office text,Region_ID int,Party_name text)CREATE TABLE party_events (Event_ID int,Event_Name text,Party_ID int,Member_in_charge_ID int)CREATE TABLE region (Region_ID int,Region_name text,Date text,Label text,Format text,Catalogue text)CREATE TABLE mem...
SELECT Minister, COUNT(Minister) FROM party WHERE Party_name <> 'Progress Party' GROUP BY Minister
What type of structure is there at the American Tower Christmas?
CREATE TABLE table_name_17 (structure_type VARCHAR,name VARCHAR)
SELECT structure_type FROM table_name_17 WHERE name = "american tower christmas"
Which New/Returning/Same Network has a Previous Network of nbc, and a Show of blockbusters?
CREATE TABLE table_46468 ("Show" text,"Last Aired" real,"Previous Network" text,"Retitled as/Same" text,"New/Returning/Same Network" text,"Returning" text)
SELECT "New/Returning/Same Network" FROM table_46468 WHERE "Previous Network" = 'nbc' AND "Show" = 'blockbusters'
WHAT MANUFACTURER AFTER 1966 HAD A START SMALLER THAN 5, A WOOD TEAM AND FINISHED 35?
CREATE TABLE table_name_5 (manufacturer VARCHAR,finish VARCHAR,team VARCHAR,year VARCHAR,start VARCHAR)
SELECT manufacturer FROM table_name_5 WHERE year > 1966 AND start < 5 AND team = "wood" AND finish = 35
i would like a flight that leaves on friday from PHILADELPHIA to DALLAS that makes a stop in ATLANTA
CREATE TABLE equipment_sequence (aircraft_code_sequence varchar,aircraft_code varchar)CREATE TABLE time_zone (time_zone_code text,time_zone_name text,hours_from_gmt int)CREATE TABLE city (city_code varchar,city_name varchar,state_code varchar,country_name varchar,time_zone_code varchar)CREATE TABLE compartment_class (c...
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, airport_service AS AIRPORT_SERVICE_2, city AS CITY_0, city AS CITY_1, city AS CITY_2, date_day, days, flight, flight_stop WHERE ((CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'ATLAN...
what's the former province with area (km 2 ) being 12,245.9
CREATE TABLE table_1404456_1 (former_province VARCHAR,area__km_2__ VARCHAR)
SELECT former_province FROM table_1404456_1 WHERE area__km_2__ = "12,245.9"
how much does flight DL 402 from DENVER to PHILADELPHIA cost
CREATE TABLE flight (aircraft_code_sequence text,airline_code varchar,airline_flight text,arrival_time int,connections int,departure_time int,dual_carrier text,flight_days text,flight_id int,flight_number int,from_airport varchar,meal_code text,stops int,time_elapsed int,to_airport varchar)CREATE TABLE class_of_service...
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE (((flight.airline_code = 'DL') AND flight.flight_number = 402) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADEL...
Name the most goals with losses less than 15 and position more than 8 with points of 42+4
CREATE TABLE table_name_18 (goals_for INTEGER,points VARCHAR,losses VARCHAR,position VARCHAR)
SELECT MAX(goals_for) FROM table_name_18 WHERE losses < 15 AND position > 8 AND points = "42+4"
Give me a bar chart to show the number of event details of events that have more than one participant.
CREATE TABLE Services (Service_ID INTEGER,Service_Type_Code CHAR(15))CREATE TABLE Participants_in_Events (Event_ID INTEGER,Participant_ID INTEGER)CREATE TABLE Events (Event_ID INTEGER,Service_ID INTEGER,Event_Details VARCHAR(255))CREATE TABLE Participants (Participant_ID INTEGER,Participant_Type_Code CHAR(15),Participa...
SELECT Event_Details, COUNT(Event_Details) FROM Events AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID = T2.Event_ID GROUP BY Event_Details
What is the smallest electorate for the Conservative party in South West Devon constituency, with over 2 conservatives and a name of Plymstock Radford?
CREATE TABLE table_name_57 (electorate INTEGER,name VARCHAR,political_party VARCHAR,constituency VARCHAR)
SELECT MIN(electorate) FROM table_name_57 WHERE political_party = "conservative" AND constituency = "south west devon" AND "conservative" > 2 AND name = "plymstock radford"
What player is from the California Golden Seals?
CREATE TABLE table_2084 ("Pick #" real,"Player" text,"Position" text,"Nationality" text,"NHL team" text,"College/junior/club team" text)
SELECT "Player" FROM table_2084 WHERE "NHL team" = 'California Golden Seals'
What was the date of the game that had a loss of Politte (0-2)?
CREATE TABLE table_name_25 (date VARCHAR,loss VARCHAR)
SELECT date FROM table_name_25 WHERE loss = "politte (0-2)"
What is the original air date of the episode written by Karen Felix and Don Woodard?
CREATE TABLE table_72210 ("Series #" real,"Season #" real,"Title" text,"Directed by" text,"Written by" text,"Original air date" text,"Production code" real)
SELECT "Original air date" FROM table_72210 WHERE "Written by" = 'Karen Felix and Don Woodard'
Most duplicated questions linked to a post.
CREATE TABLE ReviewTaskResultTypes (Id number,Name text,Description text)CREATE TABLE ReviewTaskResults (Id number,ReviewTaskId number,ReviewTaskResultTypeId number,CreationDate time,RejectionReasonId number,Comment text)CREATE TABLE PostHistoryTypes (Id number,Name text)CREATE TABLE ReviewTasks (Id number,ReviewTaskTy...
SELECT PostId AS "post_link", COUNT(RelatedPostId) AS count FROM PostLinks WHERE LinkTypeId = 3 GROUP BY PostId ORDER BY COUNT(RelatedPostId) DESC LIMIT 50
For the dates of transactions with amount smaller than 3000, bin the date into year interval, and draw a line chart to show the trend of the number of records in each bin, and order by the x-axis in desc please.
CREATE TABLE Transactions_Lots (transaction_id INTEGER,lot_id INTEGER)CREATE TABLE Transactions (transaction_id INTEGER,investor_id INTEGER,transaction_type_code VARCHAR(10),date_of_transaction DATETIME,amount_of_transaction DECIMAL(19,4),share_count VARCHAR(40),other_details VARCHAR(255))CREATE TABLE Ref_Transaction_T...
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Sales AS T1 JOIN Transactions AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000 ORDER BY date_of_transaction DESC
how many patients whose admission year is less than 2197 and procedure icd9 code is 3323?
CREATE TABLE demographic (subject_id text,hadm_id text,name text,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay text,insurance text,ethnicity text,expire_flag text,admission_location text,discharge_location text,diagnosis text,dod text,dob_year text,dod_year ...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2197" AND procedures.icd9_code = "3323"
Visualize a bar chart for simply displaying the email address of the employee and the corresponding employee id, order in ascending by the Y-axis.
CREATE TABLE employees (EMPLOYEE_ID decimal(6,0),FIRST_NAME varchar(20),LAST_NAME varchar(25),EMAIL varchar(25),PHONE_NUMBER varchar(20),HIRE_DATE date,JOB_ID varchar(10),SALARY decimal(8,2),COMMISSION_PCT decimal(2,2),MANAGER_ID decimal(6,0),DEPARTMENT_ID decimal(4,0))CREATE TABLE departments (DEPARTMENT_ID decimal(4,...
SELECT EMAIL, EMPLOYEE_ID FROM employees ORDER BY EMPLOYEE_ID
For how long has MFG 605 been offered ?
CREATE TABLE course_prerequisite (pre_course_id int,course_id int)CREATE TABLE area (course_id int,area varchar)CREATE TABLE offering_instructor (offering_instructor_id int,offering_id int,instructor_id int)CREATE TABLE student (student_id int,lastname varchar,firstname varchar,program_id int,declare_major varchar,tota...
SELECT DISTINCT semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'MFG' AND course.number = 605 AND semester.semester_id = course_offering.semester ORDER BY semester.year LIMIT 1
What is the number of patients admitted before 2190 who had a hemoglobin a1c lab test done?
CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid text)CREATE TABLE demographic (subject_id text,hadm_id text,name text,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay text,insurance text,ethni...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2190" AND lab.label = "% Hemoglobin A1c"
count the number of patients whose religion is christian scientist and item id is 51254?
CREATE TABLE procedures (subject_id text,hadm_id text,icd9_code text,short_title text,long_title text)CREATE TABLE prescriptions (subject_id text,hadm_id text,icustay_id text,drug_type text,drug text,formulary_drug_cd text,route text,drug_dose text)CREATE TABLE demographic (subject_id text,hadm_id text,name text,marita...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.religion = "CHRISTIAN SCIENTIST" AND lab.itemid = "51254"
what is distance for the 7th position?
CREATE TABLE table_25429986_1 (distance VARCHAR,position VARCHAR)
SELECT COUNT(distance) FROM table_25429986_1 WHERE position = "7th"
How many draws are there when the score is 13?
CREATE TABLE table_18594107_2 (draws INTEGER,scored VARCHAR)
SELECT MAX(draws) FROM table_18594107_2 WHERE scored = 13
What are the notes regarding the scout x-4 vehicle which ceased operation in June 1971?
CREATE TABLE table_48805 ("Name" text,"Launched" text,"Vehicle" text,"Ceased operation" text,"Notes" text)
SELECT "Notes" FROM table_48805 WHERE "Vehicle" = 'scout x-4' AND "Ceased operation" = 'june 1971'
what is the number of patients whose diagnoses short title is hemochromatos-rbc trans and drug type is base?
CREATE TABLE demographic (subject_id text,hadm_id text,name text,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay text,insurance text,ethnicity text,expire_flag text,admission_location text,discharge_location text,diagnosis text,dod text,dob_year text,dod_year ...
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Hemochromatos-rbc trans" AND prescriptions.drug_type = "BASE"
Marat Safin is the opponent in the final in what championship?
CREATE TABLE table_26202788_7 (championship VARCHAR,opponent_in_the_final VARCHAR)
SELECT championship FROM table_26202788_7 WHERE opponent_in_the_final = "Marat Safin"
List the event venues and names that have the top 2 most number of people attended.
CREATE TABLE event (venue VARCHAR,name VARCHAR,Event_Attendance VARCHAR)
SELECT venue, name FROM event ORDER BY Event_Attendance DESC LIMIT 2
what are the three most common lab tests for the patients of age 50s since 2102?
CREATE TABLE d_icd_diagnoses (row_id number,icd9_code text,short_title text,long_title text)CREATE TABLE microbiologyevents (row_id number,subject_id number,hadm_id number,charttime time,spec_type_desc text,org_name text)CREATE TABLE prescriptions (row_id number,subject_id number,hadm_id number,startdate time,enddate t...
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 50 AND 59) AND STRFTIME('%y', labevents.c...
What is the total number of draws when there are fewer than 3 wins?
CREATE TABLE table_60688 ("Golden Rivers" text,"Wins" real,"Byes" real,"Losses" real,"Draws" real,"Against" real)
SELECT COUNT("Draws") FROM table_60688 WHERE "Wins" < '3'
Give me the time of admission and diagnoses icd9 code for the patient with patient id 1875.
CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid text)CREATE TABLE demographic (subject_id text,hadm_id text,name text,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay text,insurance text,ethni...
SELECT demographic.admittime, diagnoses.icd9_code FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.subject_id = "1875"
Who scored 18-19?
CREATE TABLE table_name_69 (opponent VARCHAR,score VARCHAR)
SELECT opponent FROM table_name_69 WHERE score = "18-19"