Chinastark/bird_dataset huggingface dataset:
Database: thrombosis_prediction
Note: highest lactate dehydrogenase in the normal range refers to MAX(ldh < 500); when the data first recorded refers to MIN(first date);
Question: For the patient with the highest lactate dehydrogenase in the normal range, when was his or her data first recorded?
SQL: SELECT patient.`first date` FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.ldh < 500 ORDER BY laboratory.ldh ASC LIMIT 1
Database: thrombosis_prediction
Note: latest patient refers to id with MAX('first date'); abnormal level of lactate dehydrogenase refers to ldh >= 500;
Question: When is the latest patient's medical data recorded? This patient should have an abnormal level of lactate dehydrogenase.
SQL: SELECT patient.`first date` FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.ldh >= 500 ORDER BY patient.`first date` DESC LIMIT 1
Database: thrombosis_prediction
Note: abnormal alkaliphophatase level refers to alp >= 300; admitted to the hospital refers to admission = '+';
Question: For the patient with an abnormal alkaliphophatase level, how many of them are admitted to the hospital?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.alp >= 300 AND patient.admission = '+'
Database: thrombosis_prediction
Note: followed at the outpatient clinic refers to admission = '-'; normal level of alkaliphophatase refers to alp < 300;
Question: Among the patients followed at the outpatient clinic, how many of them have a normal level of alkaliphophatase?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.alp < 300 AND patient.admission = '-'
Database: thrombosis_prediction
Note: total protein is lower than normal refers to tp < 6.0;
Question: Please list the diagnosis of the patients whose total protein is lower than normal.
SQL: SELECT patient.diagnosis FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.tp < 6.0
Database: thrombosis_prediction
Note: diagnosed with SJS refers to diagnosis = 'SJS'; normal level of total protein refers to tp > 6.0 and tp < 8.5;
Question: For the patients who are diagnosed with SJS, how many of them have a normal level of total protein?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE patient.diagnosis = 'SJS' AND laboratory.tp > 6.0 AND laboratory.tp < 8.5
Database: thrombosis_prediction
Note: examination date refers to date; albumin is the highest in the normal range refers to MAX(alb > 3.5 and alb < 5.5);
Question: What is the examination date of the patient whose albumin is the highest in the normal range?
SQL: SELECT Date FROM laboratory WHERE alb > 3.5 AND alb < 5.5 ORDER BY alb DESC LIMIT 1
Database: thrombosis_prediction
Note: male refers to sex = 'M'; normal level of both albumin and total protein refers to alb > 3.5 and alb < 5.5 AND tp between 6.0 and 8.5;
Question: How many male patients have a normal level of both albumin and total protein?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE patient.sex = 'M'  AND laboratory.alb > 3.5 AND laboratory.alb < 5.5 AND laboratory.tp BETWEEN 6.0 AND 8.5
Database: thrombosis_prediction
Note: anti Cardiolipin antibody concentration refers to `acl igg`, `acl igm`, `acl iga`; female patient refers to sex = F'; highest uric acid level in the normal range refers to MAX(ua > 6.50);
Question: What is the anti Cardiolipin antibody concentration of the female patient with the highest uric acid level in the normal range?
SQL: SELECT examination.`acl igg`, examination.`acl igm`, examination.`acl iga` FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON examination.id = laboratory.id WHERE patient.sex = 'F' AND laboratory.ua > 6.5 ORDER BY laboratory.ua DESC LIMIT 1
Database: thrombosis_prediction
Note: highest anti-nucleus antibody concentration level refers to MAX(ana); normal creatinine level refers to cre < 1.5;
Question: What is the highest anti-nucleus antibody concentration level of a patient with a normal creatinine level?
SQL: SELECT examination.ana FROM patient INNER JOIN examination ON patient.id = examination.id INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.cre < 1.5 ORDER BY examination.ana DESC LIMIT 1
Database: thrombosis_prediction
Note: creatinine level is normal refers to cre < 1.5; anti Cardiolipin antibody concentration level is the highest refers to MAX(acl iga);
Question: Please list the patient's ID whose creatinine level is normal and whose anti Cardiolipin antibody concentration level is the highest.
SQL: SELECT examination.id FROM laboratory INNER JOIN examination ON laboratory.id = examination.id WHERE laboratory.cre < 1.5 ORDER BY examination.`acl iga` DESC LIMIT 1
Database: thrombosis_prediction
Note: total bilirubin is over the normal range refers to `t-bil` >= 2.0; peripheral pattern is observed in the sheet of ana examination refers to that ana pattern contains 'P';
Question: Among the patients whose total bilirubin is over the normal range, how many of them have a peripheral pattern observed in the sheet of ANA examination?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE laboratory.`t-bil` >= 2 AND examination.`ana pattern` LIKE '%P%'
Database: thrombosis_prediction
Note: anti-nucleus antibody concentration refers to ana; total bilirubin is the highest in the normal range refers to MAX(`t-bil` < 2.0);
Question: What is the anti-nucleus antibody concentration of the patient whose total bilirubin is the highest in the normal range?
SQL: SELECT examination.ana FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE laboratory.`t-bil` < 2.0 ORDER BY laboratory.`t-bil` DESC LIMIT 1
Database: thrombosis_prediction
Note: total cholesterol is higher than normal refers to `t-cho` >= 250; negative measure of degree of coagulation refers to kct = '-' ;
Question: For the patients whose total cholesterol is higher than normal, how many of them have a negative measure of degree of coagulation?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE laboratory.`t-cho` >= 250 AND examination.kct = '-'
Database: thrombosis_prediction
Note: total cholesterol is within the normal range refers to `t-cho` < 250; P pattern observed in the sheet of ana examination refers to ana pattern = 'P';
Question: Among the patients whose total cholesterol is within the normal range, how many of them have a P pattern observed in the sheet of ANA examination?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE examination.`ana pattern` = 'P' AND laboratory.`t-cho` < 250
Database: thrombosis_prediction
Note: normal level of triglyceride refers to tg < 200; have other symptoms refers to symptoms is not null;
Question: Among the patients with the normal level of triglyceride, how many of them have other symptoms observed?
SQL: SELECT count(examination.id) FROM examination INNER JOIN laboratory ON examination.id = laboratory.id WHERE laboratory.tg < 200 AND examination.symptoms IS NOT NULL
Database: thrombosis_prediction
Note: disease name referse to diagnosis; highest level of triglyceride within the normal range refers to MAX(tg < 200);
Question: What is the disease name of the patient who has the highest level of triglyceride within the normal range?
SQL: SELECT examination.diagnosis FROM examination INNER JOIN laboratory ON examination.id = laboratory.id WHERE laboratory.tg < 200 ORDER BY laboratory.tg DESC LIMIT 1
Database: thrombosis_prediction
Note: no thrombosis refers to thrombosis = 0 ; abnormal level of creatinine phosphokinase refers to cpk < 250;
Question: Please list the IDs of the patients with no thrombosis and an abnormal level of creatinine phosphokinase.
SQL: SELECT DISTINCT laboratory.id FROM laboratory INNER JOIN examination ON laboratory.id = examination.id WHERE examination.thrombosis = 0 AND laboratory.cpk < 250
Database: thrombosis_prediction
Note: normal range of creatinine phosphokinase refers to cpk < 250; positive measure of degree of coagulation refers to kct = '+' or rvvt = '+' or lac = '+' ;
Question: For the patients with a normal range of creatinine phosphokinase, how many of them have a positive measure of degree of coagulation?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE laboratory.cpk < 250 AND (examination.kct = '+' OR examination.rvvt = '+' OR examination.lac = '+')
Database: thrombosis_prediction
Note: oldest patient refers to MIN(birthday); blood glucose is abnormal refers to glu > 180;
Question: When is the birthday of the oldest patient whose blood glucose is abnormal?
SQL: SELECT patient.birthday FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.glu > 180 ORDER BY patient.birthday ASC LIMIT 1
Database: thrombosis_prediction
Note: normal blood glucose refers to glu < 180; don't have thrombosis refers to thrombosis = 0;
Question: Among the patients with a normal blood glucose, how many of them don't have thrombosis?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE laboratory.glu < 180 AND examination.thrombosis = 0
Database: thrombosis_prediction
Note: accepted to the hospital refers to admission = '+'; normal level of white blood cells refers to wbc between 3.5 and 9.0;
Question: How many patients accepted to the hospital have a normal level of white blood cells?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.wbc BETWEEN 3.5 AND 9 AND patient.admission = '+'
Database: thrombosis_prediction
Note: diagnosed with SLE refers to diagnosis = 'SLE'; normal white blood cell level refers to wbc between 3.5 and 9.0;
Question: How many patients diagnosed with SLE have a normal white blood cell level?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE patient.diagnosis = 'SLE' AND laboratory.wbc BETWEEN 3.5 AND 9
Database: thrombosis_prediction
Note: rbc <= 3.5 or rbc >= 6.0 means the patient has an abnormal level of red blood cell; 3.5 < rbc < 6.0 means the patient has a normal level of red blood cell; followed at the outpatient clinic refers to admission = '-';
Question: Please list the patient's ID if he or she has an abnormal level of red blood cell and is followed at the outpatient clinic.
SQL: SELECT DISTINCT patient.id FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE (laboratory.rbc <= 3.5 OR laboratory.rbc >= 6) AND patient.admission = '-'
Database: thrombosis_prediction
Note: normal platelet level refers to plt > 100 and plt < 400; have other symptoms refers to diagnosis is not null;
Question: Among the patients who have a normal platelet level, how many of them have other symptoms observed?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.plt > 100 AND laboratory.plt < 400 AND patient.diagnosis IS NOT NULL
Database: thrombosis_prediction
Note: plt > 100 and plt < 400 means platelet level is within the normal range; plt < 100 and plt > 400 means platelet level is not within the normal range; diagnosed with MCTD refers to diagnosis = 'MCTD';
Question: Please list a patient's platelet level if it is within the normal range and if he or she is diagnosed with MCTD.
SQL: SELECT laboratory.plt FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE patient.diagnosis = 'MCTD' AND laboratory.plt BETWEEN 100 AND 400
Database: thrombosis_prediction
Note: male refers to sex = 'M'; normal prothrombin time refer to pt < 14; average prothrombin time = AVG(pt);
Question: For the male patients that have a normal prothrombin time, what is their average prothrombin time?
SQL: SELECT avg(laboratory.pt) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id WHERE laboratory.pt < 14 AND patient.sex = 'M'
Database: thrombosis_prediction
Note: severe thrombosis refers to thrombosis = 2 or 1; normal prothrombin time refers to pt < 14;
Question: How many patients with severe thrombosis have a normal prothrombin time?
SQL: SELECT count(patient.id) FROM patient INNER JOIN laboratory ON patient.id = laboratory.id INNER JOIN examination ON patient.id = examination.id WHERE laboratory.pt < 14 AND examination.thrombosis < 3 AND examination.thrombosis > 0
Database: student_club
Note: Angela Sanders is the full name; full name refers to first_name, last_name; major refers to major_name.;
Question: What's Angela Sanders's major?
SQL: SELECT major.major_name FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE member.first_name = 'Angela' AND member.last_name = 'Sanders'
Database: student_club
Question: How many students in the Student_Club are from the College of Engineering?
SQL: SELECT count(member.member_id) FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE major.college = 'College of Engineering'
Database: student_club
Note: full name refers to first_name, last_name;
Question: Please list the full names of the students in the Student_Club that come from the Art and Design Department.
SQL: SELECT member.first_name, member.last_name FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE major.department = 'Art and Design Department'
Database: student_club
Note: Women's Soccer is an event name;
Question: How many students of the Student_Club have attended the event "Women's Soccer"?
SQL: SELECT count(event.event_id) FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event WHERE event.event_name = 'Women''s Soccer'
Database: student_club
Note: Women's Soccer is an event name; phone numbers refers to phone;
Question: Please list the phone numbers of the students from the Student_Club that has attended the event "Women's Soccer".
SQL: SELECT member.phone FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event INNER JOIN member ON attendance.link_to_member = member.member_id WHERE event.event_name = 'Women''s Soccer'
Database: student_club
Note: Women's Soccer is an event name; T-shirt that is in medium size refers to t_shirt_size = 'Medium';
Question: Among the students from the Student_Club who attended the event "Women's Soccer", how many of them want a T-shirt that's in medium size?
SQL: SELECT count(event.event_id) FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event INNER JOIN member ON attendance.link_to_member = member.member_id WHERE event.event_name = 'Women''s Soccer' AND member.t_shirt_size = 'Medium'
Database: student_club
Note: event with highest attendance refers to MAX(COUNT(link_to_event));
Question: What is the event that has the highest attendance of the students from the Student_Club?
SQL: SELECT event.event_name FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event GROUP BY event.event_name ORDER BY count(attendance.link_to_event) DESC LIMIT 1
Database: student_club
Note: Vice President is a position of the Student Club;
Question: Which college is the vice president of the Student_Club from?
SQL: SELECT major.college FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE member.position LIKE 'vice president'
Database: student_club
Question: Please list the event names of all the events attended by Maya Mclean.
SQL: SELECT event.event_name FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event INNER JOIN member ON attendance.link_to_member = member.member_id WHERE member.first_name = 'Maya' AND member.last_name = 'Mclean'
Database: student_club
Note: events attended in 2019 refers to YEAR(event_date) = 2019;
Question: How many events of the Student_Club did Sacha Harrison attend in 2019?
SQL: SELECT count(event.event_id) FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event INNER JOIN member ON attendance.link_to_member = member.member_id WHERE member.first_name = 'Sacha' AND member.last_name = 'Harrison' AND substr(event.event_date, 1, 4) = '2019'
Database: student_club
Note: meetings events refers to type = 'Meeting'; attended by more than 10 members refers to COUNT(event_id) > 10;
Question: Among the events attended by more than 10 members of the Student_Club, how many of them are meetings?
SQL: SELECT event.event_name FROM event  INNER JOIN attendance ON event.event_id = attendance.link_to_event GROUP BY event.event_id  HAVING count(attendance.link_to_event) > 10 EXCEPT SELECT event.event_name  FROM event  WHERE event.type = 'Meeting'
Database: student_club
Note: name of events refers to event_name; attendance of over 20 students COUNT(event_id) > 20.;
Question: List all the names of events that had an attendance of over 20 students but were not fundraisers.
SQL: SELECT event.event_name FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event GROUP BY event.event_id HAVING count(attendance.link_to_event) > 20 EXCEPT SELECT event.event_name FROM event  WHERE event.type = 'Fundraiser'
Database: student_club
Note: meetings in 2020 refers to type = 'Meeting' where YEAR(event_date) = 2020; average = DIVIDE(COUNT(event_id), COUNT(DISTINCT event_name));
Question: What is the average attendance of meetings in 2020?
SQL: SELECT cast(count(attendance.link_to_event) AS REAL) / count(DISTINCT attendance.link_to_event) FROM event INNER JOIN attendance ON event.event_id = attendance.link_to_event WHERE substr(event.event_date, 1, 4) = '2020' AND event.type = 'Meeting'
Database: student_club
Note: item in support of club events refers to expense_description; most expensive refers to MAX(cost);
Question: What is the most expensive item that was spent in support of club events?
SQL: SELECT expense_description FROM expense ORDER BY cost DESC LIMIT 1
Database: student_club
Note: 'Environmental Engineering' is the major name;
Question: How many members of the Student_Club have majored Environmental Engineering? 
SQL: SELECT count(member.member_id) FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE major.major_name = 'Environmental Engineering'
Database: student_club
Note: full name of members refers to first_name, last_name; 'Laugh Out Loud' is an event name;
Question: List the full name of all the members of the Student_Club who attended the "Laugh Out Loud" event.
SQL: SELECT member.first_name, member.last_name FROM member INNER JOIN attendance ON member.member_id = attendance.link_to_member INNER JOIN event ON attendance.link_to_event = event.event_id WHERE event.event_name = 'Laugh Out Loud'
Database: student_club
Note: 'Law and Constitutional Studies' is the major name;
Question: List the last name of all the students who majored Law and Constitutional Studies.  
SQL: SELECT member.last_name FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE major.major_name = 'Law and Constitutional Studies'
Database: student_club
Question: What county did Sherri Ramsey grew up?
SQL: SELECT zip_code.county FROM member INNER JOIN zip_code ON member.zip = zip_code.zip_code WHERE member.first_name = 'Sherri' AND member.last_name = 'Ramsey'
Database: student_club
Question: What college offers the major that Tyler Hewitt took?
SQL: SELECT major.college FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE member.first_name = 'Tyler' AND member.last_name = 'Hewitt'
Database: student_club
Note: 'Vice President' is a position of Student Club; funds received refers to amount.;
Question: What is the amount of the funds that the Vice President received?
SQL: SELECT income.amount FROM member INNER JOIN income ON member.member_id = income.link_to_member WHERE member.position = 'Vice President'
Database: student_club
Note: amount spent refers to spent; spend on food in September Meeting refers to category = 'Food' where event_name = 'September Meeting';
Question: How much did the Student_Club members spend on food in September Meeting?
SQL: SELECT budget.spent FROM event INNER JOIN budget ON event.event_id = budget.link_to_event WHERE event.event_name = 'September Meeting' AND budget.category = 'Food' AND substr(event.event_date, 6, 2) = '09'
Database: student_club
Note: 'President' is a position of Student Club;
Question: What city and state did the President of the Student_Club grow up?
SQL: SELECT zip_code.city, zip_code.state FROM member INNER JOIN zip_code ON member.zip = zip_code.zip_code WHERE member.position = 'President'
Database: student_club
Note: full name of member refers to first_name, last_name;
Question: List the full name of the Student_Club members that grew up in Illinois state.
SQL: SELECT member.first_name, member.last_name FROM member INNER JOIN zip_code ON member.zip = zip_code.zip_code WHERE zip_code.state = 'Illinois'
Database: student_club
Note: amount spent refers to spent; spend on food in September Meeting refers to category = 'Advertisement' where event_name = 'September Meeting';
Question: How much did the Student_Club members spend on advertisement in September Meeting?
SQL: SELECT budget.spent FROM event INNER JOIN budget ON event.event_id = budget.link_to_event WHERE event.event_name = 'September Meeting' AND budget.category = 'Advertisement' AND substr(event.event_date, 6, 2) = '09'
Database: student_club
Question: What department offers the major that Pierce and Guidi took?
SQL: SELECT major.department FROM member INNER JOIN major ON member.link_to_major = major.major_id WHERE member.last_name = 'Pierce' OR member.last_name = 'Guidi'
Database: student_club
Note: total budgeted amount refers to SUM(amount) where event_name = 'October Speaker';
Question: What is the total budgeted amount for all category in "October Speaker" event?
SQL: SELECT sum(budget.amount) FROM event INNER JOIN budget ON event.event_id = budget.link_to_event WHERE event.event_name = 'October Speaker'
Database: student_club
Note: event_name = 'October Meeting' where event_date = '2019-10-08'; approved = True means expenses was approved; approved = False means expenses was not approved;
Question: Was each expense in October Meeting on October 8, 2019 approved?
SQL: SELECT expense.approved FROM event INNER JOIN budget ON event.event_id = budget.link_to_event INNER JOIN expense ON budget.budget_id = expense.link_to_budget WHERE event.event_name = 'October Meeting' AND event.event_date LIKE '2019-10-08%'
Database: student_club
Note: Elijah Allen is the full name; full name refers to first_name, last_name; The 5th and 6th string of the expense_date in the expense table can refer to month; events in September and October refers to month(expense_date) = 9 OR month(expense_date) = 10;
Question: Calculate the total average cost that Elijah Allen spent in the events on September and October.
SQL: SELECT avg(expense.cost) FROM member INNER JOIN expense ON member.member_id = expense.link_to_member WHERE member.last_name = 'Allen' AND member.first_name = 'Elijah' AND (substr(expense.expense_date, 6, 2) = '09' OR substr(expense.expense_date, 6, 2) = '10')
Database: student_club
Note: The first 4 strings of the event_date values in the event table can represent year; The difference of the total amount spent = SUBTRACT(spent where YEAR(event_date) = 2019, spent where YEAR(event_date) = 2020);
Question: Calculate the difference of the total amount spent in all events by the Student_Club in year 2019 and 2020.
SQL: SELECT sum(CASE WHEN substr(event.event_date, 1, 4) = '2019' THEN budget.spent ELSE 0 END) - sum(CASE WHEN substr(event.event_date, 1, 4) = '2020' THEN budget.spent ELSE 0 END) AS num FROM event INNER JOIN budget ON event.event_id = budget.link_to_event