instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
what is average age of patients whose ethnicity is white and admission year is greater than or equal to 2123? | CREATE TABLE diagnoses (subject_id text,hadm_id text,icd9_code text,short_title text,long_title 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,ethnicity text,expire_flag... | SELECT AVG(demographic.age) FROM demographic WHERE demographic.ethnicity = "WHITE" AND demographic.admityear >= "2123" |
what are the four most frequent diagnoses that patients were diagnosed in the same hospital encounter after having received a packed cell transfusion procedure? | CREATE TABLE prescriptions (row_id number,subject_id number,hadm_id number,startdate time,enddate time,drug text,dose_val_rx text,dose_unit_rx text,route text)CREATE TABLE outputevents (row_id number,subject_id number,hadm_id number,icustay_id number,charttime time,itemid number,value number)CREATE TABLE diagnoses_icd ... | SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t3.icd9_code FROM (SELECT t2.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime, admissions.hadm_id FROM procedures_icd JOIN admissions ON procedures_i... |
what's the name of the insurance for patient 18159 on the first hospital visit? | 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 number,intime time,outtime time)CREATE TABLE transfers (row_id number,subject_id number,hadm_id number,icustay_id number,eventtype text,careunit text,wardid numb... | SELECT admissions.insurance FROM admissions WHERE admissions.subject_id = 18159 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1 |
what are the five most frequently ordered medications since 2101? | CREATE TABLE lab (labid number,patientunitstayid number,labname text,labresult number,labresulttime time)CREATE TABLE treatment (treatmentid number,patientunitstayid number,treatmentname text,treatmenttime time)CREATE TABLE vitalperiodic (vitalperiodicid number,patientunitstayid number,temperature number,sao2 number,he... | SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE STRFTIME('%y', medication.drugstarttime) >= '2101' GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5 |
WHICH Venue IS after 1992 with a Score of 1 0 and a Winners of us chaouia? | CREATE TABLE table_9456 ("Year" real,"Winners" text,"Score" text,"Runners-up" text,"Venue" text) | SELECT "Venue" FROM table_9456 WHERE "Year" > '1992' AND "Score" = '1 – 0' AND "Winners" = 'us chaouia' |
What is the nationality of the player Tom Boswell? | CREATE TABLE table_57897 ("Player" text,"Nationality" text,"Position" text,"Years for Jazz" text,"School/Club Team" text) | SELECT "Nationality" FROM table_57897 WHERE "Player" = 'tom boswell' |
Name the league for 1994 | CREATE TABLE table_57710 ("Year" text,"Division" text,"League" text,"Reg. Season" text,"Playoffs" text,"Open Cup" text) | SELECT "League" FROM table_57710 WHERE "Year" = '1994' |
Another Way for Generating Sequence Of Numbers. | CREATE TABLE Comments (Id number,PostId number,Score number,Text text,CreationDate time,UserDisplayName text,UserId number,ContentLicense text)CREATE TABLE ReviewTaskResultTypes (Id number,Name text,Description text)CREATE TABLE PostHistoryTypes (Id number,Name text)CREATE TABLE CloseAsOffTopicReasonTypes (Id number,Is... | WITH temp AS (SELECT n FROM (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9)) AS temp(n)), nums AS (SELECT t1.n * 100 + t2.n * 10 + t3.n + 1 AS n FROM temp AS t1 CROSS JOIN temp AS t2 CROSS JOIN temp AS t3) SELECT n FROM nums ORDER BY n |
What nation had more than 3 bronze, 0 gold, and a total of 9? | CREATE TABLE table_47788 ("Rank" text,"Nation" text,"Gold" real,"Silver" real,"Bronze" real,"Total" real) | SELECT "Nation" FROM table_47788 WHERE "Bronze" > '3' AND "Gold" = '0' AND "Total" = '9' |
What was the 2nd leg for 2004? | CREATE TABLE table_47626 ("Year" real,"Winner" text,"Runners-up" text,"Aggregate" text,"1st leg" text,"2nd leg" text) | SELECT "2nd leg" FROM table_47626 WHERE "Year" = '2004' |
what is the number of losses with wins less than 4 and goals against more than 39? | CREATE TABLE table_14497 ("Team" text,"Games Played" real,"Wins" real,"Losses" real,"Ties" real,"Goals For" real,"Goals Against" real) | SELECT COUNT("Losses") FROM table_14497 WHERE "Goals Against" > '39' AND "Wins" < '4' |
What is every weekly schedule of TV network Viasat 4? | CREATE TABLE table_22626 ("Country" text,"TV Network(s)" text,"Series Premiere" text,"Weekly Schedule" text,"Status" text) | SELECT "Weekly Schedule" FROM table_22626 WHERE "TV Network(s)" = 'Viasat 4' |
which patients were ordered to get wbc, pleural lab test? | 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 lab ON demographic.hadm_id = lab.hadm_id WHERE lab.label = "WBC, Pleural" |
What season has 195 runs as a margin? | CREATE TABLE table_35610 ("Rank" text,"Margin" text,"Opponent" text,"Venue" text,"Season" text) | SELECT "Season" FROM table_35610 WHERE "Margin" = '195 runs' |
What was the result of the open cup when they finished 4th in the regular season? | CREATE TABLE table_17370 ("Year" real,"Division" text,"League" text,"Reg. Season" text,"Playoffs" text,"Open Cup" text) | SELECT "Open Cup" FROM table_17370 WHERE "Reg. Season" = '4th' |
Find the maximum and average capacity among rooms in each building. | CREATE TABLE classroom (building VARCHAR,capacity INTEGER) | SELECT MAX(capacity), AVG(capacity), building FROM classroom GROUP BY building |
Name the score for game 63 | CREATE TABLE table_17288845_9 (score VARCHAR,game VARCHAR) | SELECT score FROM table_17288845_9 WHERE game = 63 |
Who is the Batsman from the year 1982? | CREATE TABLE table_name_83 (batsmen VARCHAR,year VARCHAR) | SELECT batsmen FROM table_name_83 WHERE year = "1982" |
allergy to peanuts | CREATE TABLE table_train_170 ("id" int,"alt" float,"hemoglobin_a1c_hba1c" float,"ast" float,"allergy_to_peanuts" bool,"a1c" float,"bilirubin" float,"NOUSE" float) | SELECT * FROM table_train_170 WHERE allergy_to_peanuts = 1 |
List the school color of the school that has the largest enrollment. | CREATE TABLE school (School_Colors VARCHAR,Enrollment VARCHAR) | SELECT School_Colors FROM school ORDER BY Enrollment DESC LIMIT 1 |
what are the three most frequent drugs which are prescribed to hypertension - hypertensive emergency/urgency female patients in 60 or above within 2 months after they have been diagnosed with hypertension - hypertensive emergency/urgency until 4 years ago? | CREATE TABLE medication (medicationid number,patientunitstayid number,drugname text,dosage text,routeadmin text,drugstarttime time,drugstoptime time)CREATE TABLE lab (labid number,patientunitstayid number,labname text,labresult number,labresulttime time)CREATE TABLE allergy (allergyid number,patientunitstayid number,dr... | SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hypertension - hypertensive emergency/urgency' AND... |
provide me the number of patients on main drug type prescription who have the diagnoses of poisoning by other opiates and related narcotics. | 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 = "Poisoning-opiates NEC" AND prescriptions.drug_type = "MAIN" |
What was the score fore the away team Dartford? | CREATE TABLE table_name_88 (score VARCHAR,away_team VARCHAR) | SELECT score FROM table_name_88 WHERE away_team = "dartford" |
Which Number has a Name of cooper, c. kenneth, and a Year End larger than 1984? | CREATE TABLE table_79077 ("Number" real,"Year Start" real,"Year End" real,"Name" text,"Home Club" text) | SELECT AVG("Number") FROM table_79077 WHERE "Name" = 'cooper, c. kenneth' AND "Year End" > '1984' |
Rank users by what fraction of their answers are accepted. | CREATE TABLE TagSynonyms (Id number,SourceTagName text,TargetTagName text,CreationDate time,OwnerUserId number,AutoRenameCount number,LastAutoRename time,Score number,ApprovedByUserId number,ApprovalDate time)CREATE TABLE Users (Id number,Reputation number,CreationDate time,DisplayName text,LastAccessDate time,WebsiteU... | SELECT Users.Id AS "user_link", COUNT(*) AS "Answers", CAST(COUNT(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 END) AS FLOAT) / COUNT(*) AS "Fraction" FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id INNER JOIN Users ON a.OwnerUserId = Users.Id GROUP BY Users.Id HAVING COUNT(*) >= @MinAnswers ORDER BY 'Fraction... |
what is the number of patients whose year of birth is less than 2170 and lab test name is other cells? | 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 lab (subject_id text,hadm_id text,itemid text,charttime te... | SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2170" AND lab.label = "Other Cells" |
Which Manufacturer has 1 lap and had an accident? | CREATE TABLE table_name_69 (manufacturer VARCHAR,laps VARCHAR,time_retired VARCHAR) | SELECT manufacturer FROM table_name_69 WHERE laps = 1 AND time_retired = "accident" |
Which Record has a Team of philadelphia? | CREATE TABLE table_7932 ("Game" real,"Date" text,"Team" text,"Score" text,"High points" text,"High rebounds" text,"High assists" text,"Location Attendance" text,"Record" text) | SELECT "Record" FROM table_7932 WHERE "Team" = 'philadelphia' |
How many cop apps in the season with fewer than 12 league apps? | CREATE TABLE table_name_48 (cup_apps INTEGER,league_apps INTEGER) | SELECT SUM(cup_apps) FROM table_name_48 WHERE league_apps < 12 |
count the number of patients who were diagnosed with peritoneum injury-open and did not come to hospital within 2 months since 4 years ago. | CREATE TABLE chartevents (row_id number,subject_id number,hadm_id number,icustay_id number,itemid number,charttime time,valuenum number,valueuom text)CREATE TABLE prescriptions (row_id number,subject_id number,hadm_id number,startdate time,enddate time,drug text,dose_val_rx text,dose_unit_rx text,route text)CREATE TABL... | SELECT (SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, diagnoses_icd.charttime FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'peritoneum... |
On what date did Universitario win the Torneo Apertura round after 2003 at Estadio Alejandro Villanueva? | CREATE TABLE table_47575 ("Season" real,"Date" text,"Score" text,"Winner" text,"Venue" text,"Competition round" text) | SELECT "Date" FROM table_47575 WHERE "Venue" = 'estadio alejandro villanueva' AND "Season" > '2003' AND "Competition round" = 'torneo apertura' AND "Winner" = 'universitario' |
how many games did the 201213 austin peay state governors basketball team win ? | CREATE TABLE table_204_436 (id number,"date" text,"time" text,"opponent" text,"site" text,"tv" text,"result" text,"attendance" number,"record" text) | SELECT COUNT(*) FROM table_204_436 WHERE "result" = 'w' |
How many people are from India. | CREATE TABLE ReviewRejectionReasons (Id number,Name text,Description text,PostTypeId number)CREATE TABLE Tags (Id number,TagName text,Count number,ExcerptPostId number,WikiPostId number)CREATE TABLE ReviewTasks (Id number,ReviewTaskTypeId number,CreationDate time,DeletionDate time,ReviewTaskStateId number,PostId number... | SELECT COUNT(Location), MAX(Reputation) FROM Users WHERE Location LIKE '%India%' |
how many times has the nonop cardiac/vasc exam been performed? | CREATE TABLE microbiologyevents (row_id number,subject_id number,hadm_id number,charttime time,spec_type_desc text,org_name text)CREATE TABLE admissions (row_id number,subject_id number,hadm_id number,admittime time,dischtime time,admission_type text,admission_location text,discharge_location text,insurance text,langua... | SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'nonop cardiac/vasc exam') |
How many total draws was played less than 18 with 11 losts? | CREATE TABLE table_13533 ("Place" real,"Team" text,"Played" real,"Draw" real,"Lost" real,"Goals Scored" real,"Goals Conceded" real,"Points" real) | SELECT SUM("Draw") FROM table_13533 WHERE "Lost" = '11' AND "Played" < '18' |
how many patients uses the drug code quet25? | 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 prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE prescriptions.formulary_drug_cd = "QUET25" |
so how many hours have passed since patient 005-48105 was admitted to the hospital? | CREATE TABLE vitalperiodic (vitalperiodicid number,patientunitstayid number,temperature number,sao2 number,heartrate number,respiration number,systemicsystolic number,systemicdiastolic number,systemicmean number,observationtime time)CREATE TABLE diagnosis (diagnosisid number,patientunitstayid number,diagnosisname text,... | SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.hospitaladmittime)) FROM patient WHERE patient.uniquepid = '005-48105' AND patient.hospitaldischargetime IS NULL |
Average number of answers to questions without accepted answer. | CREATE TABLE FlagTypes (Id number,Name text,Description text)CREATE TABLE ReviewTaskTypes (Id number,Name text,Description text)CREATE TABLE PostTypes (Id number,Name text)CREATE TABLE PostHistoryTypes (Id number,Name text)CREATE TABLE PostLinks (Id number,CreationDate time,PostId number,RelatedPostId number,LinkTypeId... | SELECT AVG(AnswerCount + 0.000001) FROM Posts WHERE PostTypeId = 1 AND AcceptedAnswerId IS NULL |
has patient 007-10135 been prescribed glucagon (human recombinant) 1 mg/ml solution for injection in a year before. | CREATE TABLE diagnosis (diagnosisid number,patientunitstayid number,diagnosisname text,diagnosistime time,icd9code text)CREATE TABLE microlab (microlabid number,patientunitstayid number,culturesite text,organism text,culturetakentime time)CREATE TABLE vitalperiodic (vitalperiodicid number,patientunitstayid number,tempe... | SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-10135')) AND medication.drugname = 'glucagon (human recombinant) 1 mg/... |
have patient 025-44495 undergone any vte prophylaxis - factor xa inhibitor procedure in this year? | CREATE TABLE medication (medicationid number,patientunitstayid number,drugname text,dosage text,routeadmin text,drugstarttime time,drugstoptime time)CREATE TABLE intakeoutput (intakeoutputid number,patientunitstayid number,cellpath text,celllabel text,cellvaluenumeric number,intakeoutputtime time)CREATE TABLE lab (labi... | SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-44495')) AND treatment.treatmentname = 'vte prophylaxis - factor xa inhi... |
provide the name of drug and route of administration for the drug with drug code d12.5w250l. | 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 prescriptions.drug, prescriptions.route FROM prescriptions WHERE prescriptions.formulary_drug_cd = "D12.5W250I" |
what is the notes when the rank is less than 2? | CREATE TABLE table_name_59 (notes VARCHAR,rank INTEGER) | SELECT notes FROM table_name_59 WHERE rank < 2 |
What time was achieved on Saturday 29th August by the rider who recorded 23' 18.82 97.102mph on Tuesday 25th August? | CREATE TABLE table_23465864_4 (sat_29_aug VARCHAR,tues_25_aug VARCHAR) | SELECT sat_29_aug FROM table_23465864_4 WHERE tues_25_aug = "23' 18.82 97.102mph" |
count the number of prescribed drugs patient 015-33415 has been prescribed in the last hospital encounter. | CREATE TABLE allergy (allergyid number,patientunitstayid number,drugname text,allergyname text,allergytime time)CREATE TABLE intakeoutput (intakeoutputid number,patientunitstayid number,cellpath text,celllabel text,cellvaluenumeric number,intakeoutputtime time)CREATE TABLE cost (costid number,uniquepid text,patientheal... | SELECT COUNT(*) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-33415' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hosp... |
What position does the player from arkansas play? | CREATE TABLE table_name_54 (position VARCHAR,school_country VARCHAR) | SELECT position FROM table_name_54 WHERE school_country = "arkansas" |
Show team_id from each team name, rank by the y axis from low to high. | 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_Name, Team_ID FROM basketball_match ORDER BY Team_ID |
Which rank has a team of Suzuki with under 16 points? | CREATE TABLE table_name_96 (rank VARCHAR,team VARCHAR,points VARCHAR) | SELECT rank FROM table_name_96 WHERE team = "suzuki" AND points < 16 |
When was the score l 111 122 (ot)? | CREATE TABLE table_name_84 (date VARCHAR,score VARCHAR) | SELECT date FROM table_name_84 WHERE score = "l 111–122 (ot)" |
Name the attendance for loss result and salford city reds | CREATE TABLE table_24229 ("Competition" text,"Round" text,"Opponent" text,"Result" text,"Score" text,"Home/Away" text,"Venue" text,"Attendance" text,"Date" text) | SELECT "Attendance" FROM table_24229 WHERE "Result" = 'Loss' AND "Opponent" = 'Salford City Reds' |
What was the team's record on May 17? | CREATE TABLE table_56729 ("Date" text,"Opponent" text,"Score" text,"Loss" text,"Attendance" text,"Record" text) | SELECT "Record" FROM table_56729 WHERE "Date" = 'may 17' |
How many entries are shown for an air date when the team guest captain was stephen k amos? | CREATE TABLE table_25816476_2 (air_date VARCHAR,team_guest_captain VARCHAR) | SELECT COUNT(air_date) FROM table_25816476_2 WHERE team_guest_captain = "Stephen K Amos" |
how many patients are with american indian/alaska native ethnicity and with drug name hydromorphone? | CREATE TABLE procedures (subject_id text,hadm_id text,icd9_code text,short_title text,long_title text)CREATE TABLE diagnoses (subject_id text,hadm_id text,icd9_code text,short_title text,long_title text)CREATE TABLE lab (subject_id text,hadm_id text,itemid text,charttime text,flag text,value_unit text,label text,fluid ... | SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND prescriptions.drug = "Hydromorphone" |
who is the opponent on 18 january 1993? | CREATE TABLE table_name_23 (opponent VARCHAR,date VARCHAR) | SELECT opponent FROM table_name_23 WHERE date = "18 january 1993" |
what is the name of the diagnostic that patient 022-127032 first was received since 2101? | CREATE TABLE allergy (allergyid number,patientunitstayid number,drugname text,allergyname text,allergytime time)CREATE TABLE patient (uniquepid text,patienthealthsystemstayid number,patientunitstayid number,gender text,age text,ethnicity text,hospitalid number,wardid number,admissionheight number,admissionweight number... | SELECT diagnosis.diagnosisname FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-127032')) AND STRFTIME('%y', diagnosis.diagnosistime) >= '210... |
Scores and Misc info for questions. | CREATE TABLE SuggestedEditVotes (Id number,SuggestedEditId number,UserId number,VoteTypeId number,CreationDate time,TargetUserId number,TargetRepChange number)CREATE TABLE Comments (Id number,PostId number,Score number,Text text,CreationDate time,UserDisplayName text,UserId number,ContentLicense text)CREATE TABLE PostT... | WITH VoteCounts AS (SELECT SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes, PostId FROM Votes INNER JOIN Posts ON Votes.PostId = Posts.Id WHERE ABS(CAST((JULIANDAY(CreationDate) - JULIANDAY(Posts.CreationDate)) AS INT)) < @timeWindow GROUP BY Post... |
whatis the gender wher ethe species is holland lop? | CREATE TABLE table_26615633_3 (gender VARCHAR,species VARCHAR) | SELECT gender FROM table_26615633_3 WHERE species = "Holland Lop" |
A bar chart for what are the number of the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa?, I want to sort by the y axis in ascending. | CREATE TABLE store (store_id TINYINT UNSIGNED,manager_staff_id TINYINT UNSIGNED,address_id SMALLINT UNSIGNED,last_update TIMESTAMP)CREATE TABLE address (address_id SMALLINT UNSIGNED,address VARCHAR(50),address2 VARCHAR(50),district VARCHAR(20),city_id SMALLINT UNSIGNED,postal_code VARCHAR(10),phone VARCHAR(20),last_upd... | SELECT payment_date, COUNT(payment_date) FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa' ORDER BY COUNT(payment_date) |
how many patients are with mechanical complication of colostomy and enterostormy diagnosis with abnormal lab test status? | 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,short_title text,long_title text)CREATE TABLE diagnoses (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 INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Mechanical complication of colostomy and enterostomy" AND lab.flag = "abnormal" |
Who has the most rebounds for game 42? | CREATE TABLE table_2844 ("Game" real,"Date" text,"Team" text,"Score" text,"High points" text,"High rebounds" text,"High assists" text,"Location Attendance" text,"Record" text) | SELECT "High rebounds" FROM table_2844 WHERE "Game" = '42' |
What is the total number of votes Sahlene with a place below 1 has? | CREATE TABLE table_name_4 (votes VARCHAR,artist VARCHAR,place VARCHAR) | SELECT COUNT(votes) FROM table_name_4 WHERE artist = "sahlene" AND place > 1 |
Which Col (m) has an Elevation (m) smaller than 1,624? | CREATE TABLE table_66021 ("Peak" text,"Country" text,"Elevation (m)" real,"Prominence (m)" real,"Col (m)" real) | SELECT MIN("Col (m)") FROM table_66021 WHERE "Elevation (m)" < '1,624' |
what flights from MILWAUKEE to SAN JOSE on wednesday on AA | CREATE TABLE dual_carrier (main_airline varchar,low_flight_number int,high_flight_number int,dual_airline varchar,service_name text)CREATE TABLE airline (airline_code varchar,airline_name text,note text)CREATE TABLE airport (airport_code varchar,airport_name text,airport_location text,state_code varchar,country_name va... | SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN JOSE' AND date_day.day_number = 23 AND date_day.month_number = 4 AND... |
What is the lowest Year, when Rank is greater than 85? | CREATE TABLE table_44204 ("Publication" text,"Country" text,"Accolade" text,"Year" real,"Rank" real) | SELECT MIN("Year") FROM table_44204 WHERE "Rank" > '85' |
Who is the opponent the Seattle Seahawks played when their record was 1-3? | CREATE TABLE table_15778 ("Week" real,"Date" text,"Opponent" text,"Result" text,"Game site" text,"Record" text,"Attendance" text) | SELECT "Opponent" FROM table_15778 WHERE "Record" = '1-3' |
Which authority has a rocket launch called shahpar-2? | CREATE TABLE table_11869952_1 (institutional_authority VARCHAR,rocket_launch VARCHAR) | SELECT institutional_authority FROM table_11869952_1 WHERE rocket_launch = "Shahpar-2" |
How many weeks have an Opponent of at san francisco 49ers, and an Attendance smaller than 34,354? | CREATE TABLE table_65450 ("Week" real,"Date" text,"Opponent" text,"Result" text,"Attendance" real) | SELECT COUNT("Week") FROM table_65450 WHERE "Opponent" = 'at san francisco 49ers' AND "Attendance" < '34,354' |
patient 015-52724 had been prescribed medication since 11/2105? | CREATE TABLE microlab (microlabid number,patientunitstayid number,culturesite text,organism text,culturetakentime time)CREATE TABLE patient (uniquepid text,patienthealthsystemstayid number,patientunitstayid number,gender text,age text,ethnicity text,hospitalid number,wardid number,admissionheight number,admissionweight... | SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-52724')) AND STRFTIME('%y-%m', medication.drugstarttime) >= '2105-11' |
What are the minimum, average, and maximum quantities ordered? Check all the invoices. | CREATE TABLE marketing_regions (marketing_region_code text,marketing_region_name text,marketing_region_descriptrion text,other_details text)CREATE TABLE ref_payment_methods (payment_method_code text,payment_method_description text)CREATE TABLE addresses (address_id text,line_1 text,line_2 text,city_town text,state_coun... | SELECT MIN(order_quantity), AVG(order_quantity), MAX(order_quantity) FROM invoices |
Which Third has Runners-up of 0, and Winners of 0, and a Club of far rabat? | CREATE TABLE table_name_4 (third INTEGER,club VARCHAR,runners_up VARCHAR,winners VARCHAR) | SELECT AVG(third) FROM table_name_4 WHERE runners_up = 0 AND winners = 0 AND club = "far rabat" |
what is drug name of drug code bag? | CREATE TABLE diagnoses (subject_id text,hadm_id text,icd9_code text,short_title text,long_title 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,ethnicity text,expire_flag... | SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.formulary_drug_cd = "BAG" |
count the number of patients whose age is less than 50 and item id is 50952? | 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,marital_status text,age text,dob text,gender text,language text,religion text,admission_type text,days_stay ... | SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.age < "50" AND lab.itemid = "50952" |
count the number of patients whose year of birth is less than 2047 and diagnoses short title is chr diastolic hrt fail? | 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 lab (subject_id text,hadm_id text,itemid text,charttime tex... | SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dob_year < "2047" AND diagnoses.short_title = "Chr diastolic hrt fail" |
What is the average population of the region with a density less than 487, a rank of 9, and an area larger than 377,944? | CREATE TABLE table_name_24 (population INTEGER,area__km_2__ VARCHAR,density__pop_per_km_2__ VARCHAR,rank VARCHAR) | SELECT AVG(population) FROM table_name_24 WHERE density__pop_per_km_2__ < 487 AND rank = 9 AND area__km_2__ > 377 OFFSET 944 |
What party did candidate george mcduffie (j) represent? | CREATE TABLE table_28881 ("District" text,"Incumbent" text,"Party" text,"First elected" text,"Result" text,"Candidates" text) | SELECT "Party" FROM table_28881 WHERE "Candidates" = 'George McDuffie (J)' |
Which Total has a Labour Panel smaller than 5, an Administrative Panel smaller than 1, and a National University of Ireland smaller than 2? | CREATE TABLE table_40218 ("Administrative Panel" real,"Agricultural Panel" real,"Cultural and Educational Panel" real,"Industrial and Commercial Panel" real,"Labour Panel" real,"National University of Ireland" real,"University of Dublin" real,"Nominated by the Taoiseach" real,"Total" real) | SELECT COUNT("Total") FROM table_40218 WHERE "Labour Panel" < '5' AND "Administrative Panel" < '1' AND "National University of Ireland" < '2' |
what is the number of patients whose item id is 51255 and lab test abnormal status is abnormal? | 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 lab ON demographic.hadm_id = lab.hadm_id WHERE lab.itemid = "51255" AND lab.flag = "abnormal" |
How many places according to the 2011 census of whatever population have an area of 132.79 kilometers squared? | CREATE TABLE table_14325808_1 (population__2011_census_ VARCHAR,area__km²_ VARCHAR) | SELECT COUNT(population__2011_census_) FROM table_14325808_1 WHERE area__km²_ = "132.79" |
Which venue led to a draw? | CREATE TABLE table_name_93 (venue VARCHAR,result VARCHAR) | SELECT venue FROM table_name_93 WHERE result = "draw" |
What is the average student GPA for every department? Return a pie chart. | CREATE TABLE STUDENT (STU_NUM int,STU_LNAME varchar(15),STU_FNAME varchar(15),STU_INIT varchar(1),STU_DOB datetime,STU_HRS int,STU_CLASS varchar(2),STU_GPA float(8),STU_TRANSFER numeric,DEPT_CODE varchar(18),STU_PHONE varchar(4),PROF_NUM int)CREATE TABLE COURSE (CRS_CODE varchar(10),DEPT_CODE varchar(10),CRS_DESCRIPTIO... | SELECT DEPT_CODE, AVG(STU_GPA) FROM STUDENT GROUP BY DEPT_CODE |
Which player was Pick #40? | CREATE TABLE table_67087 ("Pick #" text,"Player" text,"Position" text,"Nationality" text,"NHL team" text,"College/junior/club team" text) | SELECT "Player" FROM table_67087 WHERE "Pick #" = '40' |
how many patients whose primary disease is femoral artery thrombosis and year of death is less than or equal to 2154? | CREATE TABLE procedures (subject_id text,hadm_id text,icd9_code text,short_title text,long_title 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,ethnicity text,expire_fla... | SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "FEMORAL ARTERY THROMBOSIS" AND demographic.dod_year <= "2154.0" |
What Opponent has an Attendance that is 26,880? | CREATE TABLE table_40859 ("Week" real,"Date" text,"Opponent" text,"Result" text,"Attendance" text) | SELECT "Opponent" FROM table_40859 WHERE "Attendance" = '26,880' |
What is Nationality, when Round is less than 2, and when College/Team is 'CB L'Hospitalet'? | CREATE TABLE table_44884 ("Round" real,"Pick" real,"Position" text,"Nationality" text,"College/Team" text) | SELECT "Nationality" FROM table_44884 WHERE "Round" < '2' AND "College/Team" = 'cb l''hospitalet' |
Find the name and price of the product that has been ordered the greatest number of times. | CREATE TABLE regular_order_products (product_id VARCHAR)CREATE TABLE products (product_name VARCHAR,product_price VARCHAR,product_id VARCHAR) | SELECT t1.product_name, t1.product_price FROM products AS t1 JOIN regular_order_products AS t2 ON t1.product_id = t2.product_id GROUP BY t2.product_id ORDER BY COUNT(*) DESC LIMIT 1 |
What's the score for Toronto Maple Leafs on November 10? | CREATE TABLE table_37045 ("Date" text,"Visitor" text,"Score" text,"Home" text,"Record" text) | SELECT "Score" FROM table_37045 WHERE "Home" = 'toronto maple leafs' AND "Date" = 'november 10' |
Who is the coach of the team in Leicester? | CREATE TABLE table_1867 ("Team" text,"Location" text,"County" text,"Division" text,"Home ground" text,"Coach" text,"Captain" text) | SELECT "Coach" FROM table_1867 WHERE "Location" = 'Leicester' |
What was the attendance when Fitzroy played as home team? | CREATE TABLE table_name_2 (crowd VARCHAR,home_team VARCHAR) | SELECT COUNT(crowd) FROM table_name_2 WHERE home_team = "fitzroy" |
what kind of ground transportation is there once i get to DALLAS | CREATE TABLE ground_service (city_code text,airport_code text,transport_type text,ground_fare int)CREATE TABLE flight_stop (flight_id int,stop_number int,stop_days text,stop_airport text,arrival_time int,arrival_airline text,arrival_flight_number int,departure_time int,departure_airline text,departure_flight_number int... | SELECT DISTINCT ground_service.transport_type FROM city, ground_service WHERE city.city_name = 'DALLAS' AND ground_service.city_code = city.city_code |
What are the names of all the Japanese constructors that have earned more than 5 points, and count them by a bar chart, and list by the X-axis from low to high please. | CREATE TABLE circuits (circuitId INTEGER,circuitRef TEXT,name TEXT,location TEXT,country TEXT,lat REAL,lng REAL,alt TEXT,url TEXT)CREATE TABLE status (statusId INTEGER,status TEXT)CREATE TABLE constructorStandings (constructorStandingsId INTEGER,raceId INTEGER,constructorId INTEGER,points REAL,position INTEGER,position... | SELECT name, COUNT(name) FROM constructors AS T1 JOIN constructorStandings AS T2 ON T1.constructorId = T2.constructorId WHERE T1.nationality = "Japanese" AND T2.points > 5 GROUP BY name ORDER BY name |
Where did the home team score 14.21 (105) with a crowd larger than 13,828? | CREATE TABLE table_55571 ("Home team" text,"Home team score" text,"Away team" text,"Away team score" text,"Venue" text,"Crowd" real,"Date" text) | SELECT "Venue" FROM table_55571 WHERE "Crowd" > '13,828' AND "Home team score" = '14.21 (105)' |
What office was law preservation ticket holder William E. Barron running for? | CREATE TABLE table_41826 ("Office" text,"Democratic ticket" text,"Republican ticket" text,"Socialist ticket" text,"Constitutional ticket" text,"Law Preservation ticket" text) | SELECT "Office" FROM table_41826 WHERE "Law Preservation ticket" = 'william e. barron' |
What was the points with 7 races? | CREATE TABLE table_name_34 (points VARCHAR,races VARCHAR) | SELECT points FROM table_name_34 WHERE races = "7" |
What is the Thai name for the word abbreviated . .? | CREATE TABLE table_name_75 (thai_name VARCHAR,abbr VARCHAR) | SELECT thai_name FROM table_name_75 WHERE abbr = "มี.ค." |
What is the average quantity of stocks? | CREATE TABLE device (device_id number,device text,carrier text,package_version text,applications text,software_platform text)CREATE TABLE shop (shop_id number,shop_name text,location text,open_date text,open_year number)CREATE TABLE stock (shop_id number,device_id number,quantity number) | SELECT AVG(quantity) FROM stock |
What is the number in the series that was titled 'Past Tense'? | CREATE TABLE table_27185 ("No. in series" real,"No. in season" real,"Title" text,"Directed by" text,"Written by" text,"Original air date" text,"U.S. viewers (millions)" text) | SELECT "No. in series" FROM table_27185 WHERE "Title" = 'Past Tense' |
Who is the nominee for Best Lead Actress? | CREATE TABLE table_name_96 (nominee VARCHAR,category VARCHAR) | SELECT nominee FROM table_name_96 WHERE category = "best lead actress" |
How many students are older than average for each gender, display from low to high by the X. | CREATE TABLE Dorm_amenity (amenid INTEGER,amenity_name VARCHAR(25))CREATE TABLE Dorm (dormid INTEGER,dorm_name VARCHAR(20),student_capacity INTEGER,gender VARCHAR(1))CREATE TABLE Student (StuID INTEGER,LName VARCHAR(12),Fname VARCHAR(12),Age INTEGER,Sex VARCHAR(1),Major INTEGER,Advisor INTEGER,city_code VARCHAR(3))CREA... | SELECT Sex, COUNT(*) FROM Student WHERE Age > (SELECT AVG(Age) FROM Student) GROUP BY Sex ORDER BY Sex |
Who was the previous champion of the title won on July 7, 2010? | CREATE TABLE table_name_98 (previous_champion_s_ VARCHAR,date_won VARCHAR) | SELECT previous_champion_s_ FROM table_name_98 WHERE date_won = "july 7, 2010" |
Name the score for rebeka dremelj | CREATE TABLE table_24321 ("Draw" real,"Song" text,"Artist" text,"Panel Points" real,"Televotes" real,"Televote Points" real,"Score" real,"Placing" text) | SELECT "Score" FROM table_24321 WHERE "Artist" = 'Rebeka Dremelj' |
If the headquarters is Bharatpur, what is the maximum area? | CREATE TABLE table_24548 ("District" text,"Headquarters" text,"Area (km\u00b2)" real,"Population (2011)" real,"Division" text) | SELECT MAX("Area (km\u00b2)") FROM table_24548 WHERE "Headquarters" = 'Bharatpur' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.