Chinastark/bird_dataset huggingface dataset:
Database: social_media
Note: female users refers to gender = 'Female'; reshare refers to isreshare = 'TRUE';
Question: How many female users reshared their tweets?
SQL: SELECT count(twitter.userid) FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE USER.gender = 'Female' AND twitter.isreshare = 'TRUE'
Database: social_media
Note: country collected the most likes refers to country where Max(Sum(likes));
Question: Which country's tweets collected the most likes?
SQL: SELECT t.country FROM ( SELECT LOCATION.country, sum(twitter.likes) AS num FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid GROUP BY LOCATION.country ) t ORDER BY t.num DESC LIMIT 1
Database: social_media
Note: "tw-682723090279841798" is the tweetid;
Question: Tweet with ID tw-682723090279841798 was posted from which country?
SQL: SELECT LOCATION.country FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE twitter.tweetid = 'tw-682723090279841798'
Database: social_media
Note: "Australia" is the country;
Question: List down all the tweet text posted from Australia.
SQL: SELECT twitter.text FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.country = 'Australia'
Database: social_media
Note: "Rawang" is the city; "Selangor" is the state; "Malaysia" is the country;
Question: Write down the tweet text posted from Rawang, Selangor, Malaysia.
SQL: SELECT twitter.text FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.city = 'Rawang' AND LOCATION.state = 'Selangor' AND LOCATION.country = 'Malaysia'
Database: social_media
Note: "Brazil" is the country; language refers to lang;
Question: Tweets that were posted from Brazil are in what languague?
SQL: SELECT DISTINCT twitter.lang FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.country = 'Brazil'
Database: social_media
Note: country with the most positive sentiment tweet refers to country where Max(Count(sentiment > 0));
Question: State the country where the most positive sentiment tweets were posted.
SQL: SELECT t.country FROM ( SELECT LOCATION.country, sum(twitter.sentiment) AS num FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE twitter.sentiment > 0 GROUP BY LOCATION.country ) t ORDER BY t.num DESC LIMIT 1
Database: social_media
Note: 'ru' refers to lang = 'ru'; male user refers to gender = 'Male';
Question: Calculate the total likes collected by tweets in `ru` posted by male users.
SQL: SELECT sum(twitter.likes) FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE twitter.lang = 'ru' AND USER.gender = 'Male'
Database: social_media
Note: male user refers to gender = 'Male'; average tweet in a week per user refers to Divide ( Divide(Count(tweetid), Count (userid)), Divide(31, 7));
Question: Calculate the average number of male users who posted tweets in a week.
SQL: SELECT count(DISTINCT twitter.tweetid) / count(DISTINCT twitter.userid) / 7 AS AVG FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE USER.gender = 'Male' AND twitter.day BETWEEN 1 AND 31
Database: social_media
Note: klout of over 50 refers to klout > 50;
Question: How many tweets have a klout of over 50?
SQL: SELECT count(DISTINCT tweetid) FROM twitter WHERE klout > 50
Database: social_media
Note: not in English refers to lang <> en';
Question: Please list the texts of all the tweets that are not in English.
SQL: SELECT text FROM twitter WHERE lang != 'en'
Database: social_media
Note: users with the most tweet refers to userid where Max(Count (tweetid));
Question: Please give the user ID of the user who has posted the most tweets.
SQL: SELECT userid FROM twitter GROUP BY userid ORDER BY count(DISTINCT tweetid) DESC LIMIT 1
Database: social_media
Note: "Monday" is the weekday; reshare refers to isreshare = 'TRUE';
Question: Among all the tweets posted on Mondays, how many of them are reshared?
SQL: SELECT count(DISTINCT tweetid) FROM twitter WHERE weekday = 'Monday' AND isreshare = 'TRUE'
Database: social_media
Note: the most number of unique users seeing refers to Max(reach);
Question: Please list the texts of the top 3 tweets with the most number of unique users seeing the tweet.
SQL: SELECT text FROM twitter ORDER BY reach DESC LIMIT 3
Database: social_media
Note: over 100 likes refers to likes > 100; reshare tweet refers to isreshare = 'TRUE';
Question: How many reshared tweets have over 100 likes?
SQL: SELECT count(DISTINCT tweetid) FROM twitter WHERE isreshare = 'TRUE' AND likes > 100
Database: social_media
Note: male user refers to gender = 'Male; 'Monday' is the weekday; total number of tweet refers to Count (tweetid);
Question: What is the total number of tweets sent by male users on Mondays?
SQL: SELECT count(DISTINCT twitter.tweetid) FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE USER.gender = 'Male' AND twitter.weekday = 'Monday'
Database: social_media
Note: tweet got the most likes refers to Max(likes);
Question: What is the gender of the user who has posted the tweet that got the most likes?
SQL: SELECT USER.gender FROM twitter INNER JOIN USER ON twitter.userid = USER.userid ORDER BY twitter.likes DESC LIMIT 1
Database: social_media
Note: "French" is the language and refers to lang = 'fr'; male user refers to gender = 'Male';
Question: Please list the texts of all the tweets in French posted by male users.
SQL: SELECT twitter.text FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE USER.gender = 'Male' AND twitter.lang = 'fr'
Database: social_media
Note: "French" is the language and refers to lang = 'fr'; 'Australia' is the country;
Question: How many tweets in French were posted from Australia?
SQL: SELECT count(DISTINCT twitter.tweetid) FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE twitter.lang = 'fr' AND LOCATION.country = 'Australia'
Database: social_media
Note: tweet with positive sentiment refers to sentiment > 0; male user refers to gender = 'Male'; 'Australia' is the country;
Question: Among all the tweets with a positive sentiment, how many of them were posted by male users in Australia?
SQL: SELECT count(twitter.tweetid) FROM twitter INNER JOIN LOCATION ON LOCATION.locationid = twitter.locationid INNER JOIN USER ON USER.userid = twitter.userid WHERE LOCATION.country = 'Australia' AND USER.gender = 'Male' AND twitter.sentiment > 0
Database: social_media
Note: positive sentiment tweet refers to sentiment > 0; neutral sentiment refers to sentiment = 0; male user refers to gender = 'Male'; difference = Subtract (Count (tweetid where sentiment > 0), Count (tweetid where sentiment = 0));
Question: How many more tweets with a positive sentiment than the tweets with a neutral sentiment were posted by male users?
SQL: SELECT sum(CASE WHEN twitter.sentiment > 0 THEN 1 ELSE 0 END) - sum(CASE WHEN twitter.sentiment = 0 THEN 1 ELSE 0 END) AS diff FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE USER.gender = 'Male'
Database: social_media
Note: tweet with most number of retweet post refers to Max(retweetcount);
Question: From which city was the tweet with the most number of retweets posted?
SQL: SELECT LOCATION.city FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid ORDER BY twitter.retweetcount DESC LIMIT 1
Database: social_media
Note: "Bangkok" and "Chiang Mai" are both city;
Question: From which city were more tweets posted, Bangkok or Chiang Mai?
SQL: SELECT sum(CASE WHEN LOCATION.city = 'Bangkok' THEN 1 ELSE 0 END) AS bnum , sum(CASE WHEN LOCATION.city = 'Chiang Mai' THEN 1 ELSE 0 END) AS cnum FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.city IN ('Bangkok', 'Chiang Mai')
Database: social_media
Note: "Sante Fe" is the state; "Argentina" is the country; posted on 31st refers to day = 31;
Question: Among the tweets posted from Santa Fe state in Argentina, how many of them were posted on 31st?
SQL: SELECT count(twitter.tweetid) FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE twitter.day = 31 AND LOCATION.state = 'Santa' AND LOCATION.country = 'Argentina'
Database: social_media
Note: "Canada" is the country; city with most number of tweets refers to city where Max(Count(tweetid));
Question: Please list the top 3 cities with the most number of tweets posted in Canada.
SQL: SELECT t.city FROM ( SELECT LOCATION.city, count(twitter.tweetid) AS num FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.country = 'Canada' GROUP BY LOCATION.city ) t ORDER BY t.num DESC LIMIT 3
Database: social_media
Note: neutral sentiment refers to sentiment = 0;
Question: Please list all the cities from where tweets with neutral sentiments were posted.
SQL: SELECT DISTINCT LOCATION.city FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE sentiment = 0
Database: social_media
Note: male user refers to gender = 'Male'; 'Argentina' is the country; most number of likes refers to Max(likes);
Question: Among all the tweets sent by male users in Argentina, what is the text of the one with the most number of likes?
SQL: SELECT twitter.text FROM USER INNER JOIN twitter ON USER.userid = twitter.userid INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.country = 'Argentina' AND USER.gender = 'Male' ORDER BY twitter.likes DESC LIMIT 1
Database: social_media
Note: male user refers to gender = 'Male'; 'Monday' is the weekday; average number of likes = Divide (Sum(likes), Count(tweetid));
Question: What is the average number of likes for a tweet posted by a male user on Mondays?
SQL: SELECT sum(twitter.likes) / count(twitter.tweetid) FROM twitter INNER JOIN USER ON twitter.userid = USER.userid WHERE USER.gender = 'Male' AND twitter.weekday = 'Monday'
Database: social_media
Note: "Bangkok" and "Chiang Mai" are both city; average number of like = Divide (Sum(likes), Count(tweetid));
Question: Tweets posted from which city has a higher number of average likes, Bangkok or Chiang Mai?
SQL: SELECT sum(CASE WHEN LOCATION.city = 'Bangkok' THEN likes ELSE NULL END) / count(CASE WHEN LOCATION.city = 'Bangkok' THEN 1 ELSE 0 END) AS bnum , sum(CASE WHEN city = 'Chiang Mai' THEN likes ELSE NULL END) / count(CASE WHEN city = 'Chiang Mai' THEN tweetid ELSE NULL END) AS cnum FROM twitter INNER JOIN LOCATION ON twitter.locationid = LOCATION.locationid WHERE LOCATION.city IN ('Bangkok', 'Chiang Mai')
Database: cs_semester
Note: diff refers to difficulty; diff is higher means the course is more difficult;
Question: Which course is more difficult, Intro to BlockChain or Computer Network?
SQL: SELECT name FROM course WHERE name = 'Intro to BlockChain' OR name = 'Computer Network' ORDER BY diff DESC LIMIT 1
Database: cs_semester
Note: lower credit means less important;
Question: Please list the names of the courses that are less important than Machine Learning Theory.
SQL: SELECT name FROM course WHERE credit < ( SELECT credit FROM course WHERE name = 'Machine Learning Theory' )
Database: cs_semester
Note: higher popularity means the professor is more popular;
Question: How many professors are more popular than Zhou Zhihua?
SQL: SELECT count(prof_id) FROM prof WHERE popularity > ( SELECT popularity FROM prof WHERE first_name = 'Zhihua' AND last_name = 'Zhou' )
Database: cs_semester
Question: What is the phone number of Kerry Pryor?
SQL: SELECT phone_number FROM student WHERE l_name = 'Pryor' AND f_name = 'Kerry'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; full name refers to f_name and l_name;
Question: Which professor advised Faina Mallinar to become a research assistant? Please give his or her full name.
SQL: SELECT prof.first_name, prof.last_name FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE student.f_name = 'Faina' AND student.l_name = 'Mallinar'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra;
Question: How many research assistants does Sauveur Skyme have?
SQL: SELECT count(ra.student_id) FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id WHERE prof.first_name = 'Sauveur' AND prof.last_name = 'Skyme'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; the highest research capability refers to capability = 5; full name refers to f_name and l_name;
Question: Please list the full names of all the students who are research assistants with the highest research capability.
SQL: SELECT student.f_name, student.l_name FROM student INNER JOIN ra ON student.student_id = ra.student_id WHERE ra.capability = 5
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; average salary refers to salary = 'med';
Question: How many research assistants of Ogdon Zywicki have an average salary?
SQL: SELECT count(ra.prof_id) FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id WHERE prof.first_name = 'Ogdon' AND ra.salary = 'med' AND prof.last_name = 'Zywicki'
Database: cs_semester
Note: full name refers to f_name and l_name;
Question: Please list the full names of all the students who took the course Machine Learning Theory.
SQL: SELECT student.f_name, student.l_name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Machine Learning Theory'
Database: cs_semester
Note: B refers to grade; gpa is an abbreviated name of grade Point Average where over 3 refers to gpa > 3;
Question: Among the students who got a B in the course Machine Learning Theory, how many of them have a gpa of over 3?
SQL: SELECT count(student_id) FROM registration WHERE grade = 'B' AND student_id IN ( SELECT student_id FROM student WHERE gpa > 3 AND course_id IN ( SELECT course_id FROM course WHERE name = 'Machine Learning Theory' ) )
Database: cs_semester
Question: Please list the names of the courses taken by Laughton Antonio.
SQL: SELECT course.name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE student.f_name = 'Laughton' AND student.l_name = 'Antonio'
Database: cs_semester
Note: If grade is NULL, it means that this student fails to pass the course; full name refers to f_name and l_name;
Question: Which student failed the course Intro to Database 2? Please give his or her full name.
SQL: SELECT student.f_name, student.l_name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE registration.grade IS NULL AND course.name = 'Intro to Database 2'
Database: cs_semester
Note: sat refers to student's satisfaction degree with the course; more satisfied refers to MAX(sat);
Question: Which student is more satisfied with the course Machine Learning Theory, Willie Rechert or Laughton Antonio?
SQL: SELECT student.f_name, student.l_name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE (student.f_name = 'Laughton' OR student.f_name = 'Willie') AND (student.l_name = 'Antonio' OR student.l_name = 'Rechert') AND course.name = 'Machine Learning Theory' ORDER BY registration.sat DESC LIMIT 1
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; more than 3 research assistant refers to COUNT(student_id) > 3;
Question: Among the professors who have more than 3 research assistants, how many of them are male?
SQL: SELECT count(*) FROM ( SELECT prof.prof_id FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id WHERE prof.gender = 'Male' GROUP BY ra.prof_id HAVING count(ra.student_id) > 3 )
Database: cs_semester
Note: UG is an abbreviated name of undergraduate student in which type = 'UG';
Question: Among the students who took the course Machine Learning Theory, how many of them are undergraduates?
SQL: SELECT count(student.student_id) FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Machine Learning Theory' AND student.type = 'UG'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; prof_id refers to professor’s ID; full name refers to f_name and l_name;
Question: Which professor advised Willie Rechert to work as a research assistant? Please give his or her full name.
SQL: SELECT prof.first_name, prof.last_name FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE student.f_name = 'Willie' AND student.l_name = 'Rechert'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; prof_id refers to professor’s ID; gpa is an abbreviated name of grade Point Average where average = AVG(gpa);
Question: What is the average gpa of Ogdon Zywicki's research assistants?
SQL: SELECT sum(student.gpa) / count(ra.student_id) FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE prof.first_name = 'Ogdon' AND prof.last_name = 'Zywicki'
Database: cs_semester
Note: sat refers to student's satisfaction degree with the course;
Question: What is the average satisfying degree of the course Machine Learning Theory?
SQL: SELECT cast(sum(registration.sat) AS REAL) / count(registration.student_id) FROM registration INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Machine Learning Theory'
Database: cs_semester
Note: RPG is an abbreviated name of research postgraduate student in which type = 'RPG';
Question: Give the number of research postgraduate students.
SQL: SELECT count(student_id) FROM student WHERE TYPE = 'RPG'
Database: cs_semester
Note: gpa is an abbreviated name of grade Point Average where highest gpa = MAX(gpa); full name refers to f_name and l_name;
Question: Which student has the highest gpa? Give the full name.
SQL: SELECT f_name, l_name FROM student WHERE gpa = ( SELECT max(gpa) FROM student )
Database: cs_semester
Note: diff refers to difficulty; diff is higher means the course is more difficult in which easiest difficulty refers to diff = 1; 3-credit course refers to credit = '3'; get an "A" refers to grade = 'A' for the course;
Question: For the 3-credit course with the easiest difficulty, how many students get an "A" in that course?
SQL: SELECT count(registration.student_id) FROM registration INNER JOIN course ON registration.course_id = course.course_id WHERE registration.grade = 'A' AND course.credit = '3' AND course.diff = 1
Database: cs_semester
Note: diff refers to difficulty; diff is higher means the course is more difficult in which hardest difficulty is expressed as diff = 5;
Question: How many students took the hardest course?
SQL: SELECT count(registration.student_id) FROM registration INNER JOIN course ON registration.course_id = course.course_id WHERE course.diff = 5
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; full name refers to f_name and l_name;
Question: Which professor is Oliy Spratling working with? Give the full name.
SQL: SELECT prof.first_name, prof.last_name FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE student.f_name = 'Oliy' AND student.l_name = 'Spratling'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; higher popularity means more popular; prof_id refers to professor’s ID;
Question: For the professor who is working with Harrietta Lydford, how is his popularity?
SQL: SELECT prof.popularity FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE student.f_name = 'Harrietta' AND student.l_name = 'Lydford'
Database: cs_semester
Note: research assistant refers to the student who serves for research where the abbreviation is ra; professor with the lowest teaching ability refers to prof_id where teachability = '1';
Question: How many research assistants does the female professor with the lowest teaching ability have?
SQL: SELECT count(ra.student_id) FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id WHERE prof.teachingability = '1' AND prof.gender = 'Female'
Database: cs_semester
Note: professor advising more than 2 students refers to COUNT(student_id) > 2; higher teachability refers to MAX(teachingability); full name refers to f_name and l_name;
Question: For the professors who advise more than 2 students, which professor has a higher teaching ability? Give the full name.
SQL: SELECT t.first_name, t.last_name FROM ( SELECT prof.first_name, prof.last_name, prof.teachingability FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id GROUP BY ra.prof_id HAVING count(student_id) > 2 ) t ORDER BY t.teachingability DESC LIMIT 1
Database: cs_semester
Note: Academic grades awarded for participation in a course are A, B, C, D and F where grade 'A' means excellent, grade 'B' means good, grade 'C' means fair, grade 'D' means poorly pass, if grade is null or empty, it means that this student fails to pass this course in which grade = NULL;
Question: Give the grade score for Rik Unsworth in "Computer Network".
SQL: SELECT CASE grade WHEN 'A' THEN 4 WHEN 'B' THEN 3 WHEN 'C' THEN 2 ELSE 1 END AS RESULT FROM registration WHERE student_id IN ( SELECT student_id FROM student WHERE f_name = 'Rik' AND l_name = 'Unsworth' AND course_id IN ( SELECT course_id FROM course WHERE name = 'Computer Network' ) )
Database: cs_semester
Question: How many courses does Alvera McQuillin take?
SQL: SELECT count(registration.course_id) FROM registration INNER JOIN student ON registration.student_id = student.student_id WHERE student.f_name = 'Alvera' AND student.l_name = 'McQuillin'
Database: cs_semester
Note: research postgraduate student refers to type = 'RPG'; research assistant refers to the student who serves for research where the abbreviation is ra;
Question: State the name of research postgraduate student among Professor Zhihua Zhou's research assistants.
SQL: SELECT student.f_name, student.l_name FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE prof.first_name = 'Zhihua' AND student.type = 'RPG' AND prof.last_name = 'Zhou'
Database: cs_semester
Question: Provide the number of students enrolled in the "Statistical Learning" course.
SQL: SELECT count(registration.student_id) FROM course INNER JOIN registration ON course.course_id = registration.course_id WHERE course.name = 'Statistical learning'
Database: cs_semester
Note: If grade is null or empty, it means that this student fails to pass the course in which grade = NULL;
Question: Who were the students who failed the course "Applied Deep Learning"? Give the full name.
SQL: SELECT student.f_name, student.l_name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Applied Deep Learning ' AND registration.grade IS NULL
Database: cs_semester
Note: A refers to an excellent grade in which grade = 'A' for the course;
Question: Give the phone number of the only student who obtained "A" in the course "Intro to BlockChain".
SQL: SELECT student.phone_number FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Intro to BlockChain' AND registration.grade = 'A'