Chinastark/bird_dataset huggingface dataset:
Database: codebase_community
Note: "Understanding what Dassault iSight is doing?" is the title of post; user refers to displayname;
Question: Which user made a post titled 'Understanding what Dassault iSight is doing?' and how much is the reputation of the user?
SQL: SELECT users.displayname, users.reputation FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE posts.title = 'Understanding what Dassault iSight is doing?'
Database: codebase_community
Note: "How does gentle boosting differ from AdaBoost?" is the title of post; comments refers to text;
Question: Write all comments made on the post titled 'How does gentle boosting differ from AdaBoost?'
SQL: SELECT comments.text FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE posts.title = 'How does gentle boosting differ from AdaBoost?'
Database: codebase_community
Note: "Necromancer" is the name of badge; users refers to displayname;
Question: Name 10 users with the badge name 'Necromancer.'
SQL: SELECT users.displayname FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.name = 'Necromancer' LIMIT 10
Database: codebase_community
Note: 'Open source tools for visualizing multi-dimensional data' is the title of Post; editor refers to displayname;
Question: Who is the editor of the post titled 'Open source tools for visualizing multi-dimensional data?'
SQL: SELECT users.displayname FROM posts INNER JOIN users ON posts.owneruserid = users.id WHERE posts.title = 'Open source tools for visualizing multi-dimensional data?'
Database: codebase_community
Note: "Vebjorn Ljosa" is the displayname; last edited refers to lasteditoruserid;
Question: List the title of posts which were edited by Vebjorn Ljosa.
SQL: SELECT posts.title FROM posts INNER JOIN users ON posts.owneruserid = users.id WHERE users.displayname = 'Vebjorn Ljosa'
Database: codebase_community
Note: "Yevgeny" is the displayname; edited refers to lasteditoruserid;
Question: What is the total score of the posts edited by Yevgeny and include the user's website URL.
SQL: SELECT sum(posts.score), users.websiteurl FROM posts INNER JOIN users ON posts.lasteditoruserid = users.id WHERE users.displayname = 'Yevgeny' GROUP BY users.websiteurl
Database: codebase_community
Note: "Why square the difference instead of taking the absolute value in standard deviation?" is the title of post;
Question: Write all the comments left by users who edited the post titled 'Why square the difference instead of taking the absolute value in standard deviation?'
SQL: SELECT posthistory.comment FROM posts INNER JOIN posthistory ON posts.id = posthistory.postid WHERE posts.title = 'Why square the difference instead of taking the absolute value in standard deviation?'
Database: codebase_community
Note: About data means the title contains 'data'; total bounty Amount refers to Sum(bountyamount);
Question: How much is the total bounty amount of the post titled about 'data'
SQL: SELECT sum(votes.bountyamount) FROM posts INNER JOIN votes ON posts.id = votes.postid WHERE posts.title LIKE '%data%'
Database: codebase_community
Note: bounty amount of 50 refers to bountyamount = 50; user refers to displayname; title mentioning variance refers to title include 'variance';
Question: Which user added a bounty amount of 50 to the post title mentioning variance?
SQL: SELECT users.displayname, posts.title FROM posts INNER JOIN votes ON posts.id = votes.postid INNER JOIN users ON users.id = votes.userid WHERE votes.bountyamount = 50 AND posts.title LIKE '%variance%'
Database: codebase_community
Note: tagged as  'humor' refers to tag = '<humor>'; comment of the post refers to text; average view count = AVG(viewcount);
Question: Calculate the average view count of each post tagged as 'humor' and list the title and the comment of each post.
SQL: SELECT avg(posts.viewcount), posts.title, comments.text FROM comments INNER JOIN posts ON posts.id = comments.postid  WHERE posts.tags = '<humor>' GROUP BY posts.title, comments.text
Database: codebase_community
Question: Give the total number of comments posted by user ID 13.
SQL: SELECT count(id) FROM comments WHERE userid = 13
Database: codebase_community
Note: highest reputation refers to Max(reputation);
Question: Which user ID has the highest reputation?
SQL: SELECT id FROM users WHERE reputation = ( SELECT max(reputation) FROM users )
Database: codebase_community
Note: lowest views refers to Min(views);
Question: Which user ID has the lowest view?
SQL: SELECT id FROM users WHERE VIEWS = ( SELECT min(VIEWS) FROM users )
Database: codebase_community
Note: "Supporter" is the name of badge; in year 2011 refers to year(date) = 2011;
Question: How many users are awarded with supporter badge during year 2011?
SQL: SELECT count(id) FROM badges WHERE strftime('%Y', Date) = '2011' AND name = 'Supporter'
Database: codebase_community
Note: more than 5 badges refers to count (name) > 5; user refers to userid;
Question: How many users are awarded with more than 5 badges?
SQL: SELECT count(userid) FROM ( SELECT userid, count(name) AS num FROM badges GROUP BY userid ) t WHERE t.num > 5
Database: codebase_community
Note: "Supporter" and "Teachers" are both name of badge; 'New York' is the location; user refers to userid;
Question: How many users from New York have a teacher and supporter badge?
SQL: SELECT count(DISTINCT badges.id) FROM badges INNER JOIN users ON badges.userid = users.id WHERE badges.name IN ('Supporter', 'Teacher') AND users.location = 'New York'
Database: codebase_community
Question: Which user created post ID 1 and what is the reputation of this user?
SQL: SELECT users.id, users.reputation FROM comments INNER JOIN users ON comments.userid = users.id WHERE comments.postid = 1
Database: codebase_community
Note: having at least 1000 view refers to views >= 1000; user refers to userid;
Question: Which user have only one post history per post and having at least 1000 views?
SQL: SELECT posthistory.userid FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posthistory.postid = posts.id WHERE posts.viewcount >= 1000 GROUP BY posthistory.userid HAVING count(DISTINCT posthistory.posthistorytypeid) = 1
Database: codebase_community
Note: user with the most comments refers to userid where Max(count(id);
Question: Which users have posted the most comments. List out the user's badge?
SQL: SELECT name FROM badges INNER JOIN comments ON badges.userid = comments.userid GROUP BY comments.userid ORDER BY count(comments.userid) DESC LIMIT 1
Database: codebase_community
Note: "India" is the location; "Teacher" is the name of badge;
Question: How many users from India have the teacher badges?
SQL: SELECT count(badges.id) FROM badges INNER JOIN users ON badges.userid = users.id WHERE users.location = 'India' AND badges.name = 'Teacher'
Database: codebase_community
Note: student badges refers to badge's name = 'Student'; during 2010 refers to Year(date) = 2010; during 2011 refers to Year(date) = 2011; percentage difference = Subtract (Divide(count(name where Year(date) = 2010), count (name)) *100, Divide(count(name where Year(date) = 2011), count(name)) * 100);
Question: What is the percentage difference of student badges given during 2010 and 2011?
SQL: SELECT cast(sum(iif(strftime('%Y', Date) = '2010', 1, 0)) AS REAL) * 100 / count(id) - cast(sum(iif(strftime('%Y', Date) = '2011', 1, 0)) AS REAL) * 100 / count(id) FROM badges WHERE name = 'Student'
Database: codebase_community
Question: What are the post history type IDs for post ID 3720 and how many unique users have commented on the post?
SQL: SELECT posthistory.posthistorytypeid, (SELECT count(DISTINCT userid) FROM comments WHERE postid = 3720) AS numberofusers FROM posthistory WHERE posthistory.postid = 3720
Database: codebase_community
Note: post related refers to relatedpostid; popularity refers to viewcount;
Question: List out all post that are related to post ID 61217 and what is the popularity of this post?
SQL: SELECT posts.viewcount FROM posts INNER JOIN postlinks ON posts.id = postlinks.postid WHERE postlinks.postid = 61217
Database: codebase_community
Question: What is the score and the link type ID for post ID 395?
SQL: SELECT posts.score, postlinks.linktypeid FROM posts INNER JOIN postlinks ON posts.id = postlinks.postid WHERE postlinks.postid = 395
Database: codebase_community
Note: score more than 60 refers to score > 60;
Question: List out all post ID with score more than 60 and list out all the user ID that created these post.
SQL: SELECT postid, userid FROM posthistory WHERE postid IN ( SELECT id FROM posts WHERE score > 60 )
Database: codebase_community
Note: in 2011 refers to year (Creatindate) = 2011;
Question: What is the sum of favourite count gained by user ID 686 in 2011?
SQL: SELECT sum(DISTINCT favoritecount) FROM posts WHERE id IN ( SELECT postid FROM posthistory WHERE userid = 686 AND strftime('%Y', creationdate) = '2011' )
Database: codebase_community
Note: creating more than 10 post refers to count (userid) > 10; average of the up votes = Divide (Sum(upvotes), count (userid)); average age = Divide (Sum(age), count(userid));
Question: What is the average of the up votes and the average user age for users creating more than 10 posts?
SQL: SELECT avg(users.upvotes), avg(users.age) FROM users INNER JOIN ( SELECT owneruserid, count(*) AS post_count FROM posts GROUP BY owneruserid HAVING post_count > 10) AS t2 ON users.id = t2.owneruserid
Database: codebase_community
Note: "Announcer" is the name of badge; user refers to userid;
Question: How many users obtained the "Announcer" badge?
SQL: SELECT count(id) FROM badges WHERE name = 'Announcer'
Database: codebase_community
Note: on 7/19/2010 7:39:08 PM refers to date = '2010-07-19 19:39:08.0';
Question: List out the name of badges that users obtained on 7/19/2010 7:39:08 PM.
SQL: SELECT name FROM badges WHERE Date = '2010-07-19 19:39:08.0'
Database: codebase_community
Note: Positive comment refers to score > 60;
Question: How many positive comments are there on the list?
SQL: SELECT count(id) FROM comments WHERE score > 60
Database: codebase_community
Note: detailed content of the comment refers to text; created on 7/19/2010 7:16:14 PM refers to creationdate = '2010-07-19 19:16:14.0';
Question: State the detailed content of the comment which was created on 7/19/2010 7:25:47 PM.
SQL: SELECT Text FROM comments WHERE creationdate = '2010-07-19 19:16:14.0'
Database: codebase_community
Note: score of 10 refers to score = 10; post refers to id;
Question: How many posts have a score of 10 on the list?
SQL: SELECT count(id) FROM posts WHERE score = 10
Database: codebase_community
Note: highest reputation refers to Max(reputation); user refers to userid;
Question: What are the name of badge that users who have the highest reputation obtained?
SQL: SELECT badges.name FROM users INNER JOIN badges ON users.id = badges.userid ORDER BY users.reputation DESC LIMIT 1
Database: codebase_community
Note: on 7/19/2010 7:39:08 PM refers to date = '2010-07-19 19:39:08.0';
Question: Mention the reputation of users who had obtained the badge on 7/19/2010 7:39:08 PM.
SQL: SELECT users.reputation FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.date = '2010-07-19 19:39:08.0'
Database: codebase_community
Question: What is the name of badge that the user whose display name is "Pierre" obtained?
SQL: SELECT badges.name FROM users INNER JOIN badges ON users.id = badges.userid WHERE users.displayname = 'Pierre'
Database: codebase_community
Note: "Rochester, NY" is the location of user; user refers to userid;
Question: List out the dates that users who are located in Rochester, NY obtained their badges?
SQL: SELECT badges.date FROM users INNER JOIN badges ON users.id = badges.userid WHERE users.location = 'Rochester, NY'
Database: codebase_community
Note: "Teacher" is the name of badge;  percentage = Divide (count(userid where it's "Teacher"), count(userid)) * 100;
Question: Among the users who obtained the "Teacher" badge, calculate their percentage of users
SQL: SELECT cast(count(users.id) AS REAL) * 100 / (SELECT count(id) FROM users) FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.name = 'Teacher'
Database: codebase_community
Note: "Organizer" is the name of badge; teenager refers to age BETWEEN 13 AND 18; percentage = Divide (count(userid where age BETWEEN 13 AND 18), count(userid)) *100;
Question: Among the users who obtained the "Organizer" badges, calculate the percentage of users who are teenagers.
SQL: SELECT cast(sum(iif(users.age BETWEEN 13 AND 18, 1, 0)) AS REAL) * 100 / count(badges.id) FROM badges INNER JOIN users ON badges.userid = users.id WHERE badges.`name` = 'Organizer'
Database: codebase_community
Note: created on 7/19/2010 7:19:56 PM refers to creationdate = '2010-07-19 19:19:56.0';
Question: What is the comment's rating score of the post which was created on 7/19/2010 7:19:56 PM
SQL: SELECT comments.score FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE comments.creationdate = '2010-07-19 19:19:56.0'
Database: codebase_community
Note: detailed content of the comment refers to text; created on 7/19/2010 7:37:33 PM creationdate = 2010-07-19 19:37:33.0';
Question: What is the detailed content of the comment of the post which was created on 7/19/2010 7:37:33 PM?
SQL: SELECT comments.text FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE comments.creationdate = '2010-07-19 19:37:33.0'
Database: codebase_community
Note: "Vienna, Austria" is the location;
Question: List out the age of users who located in Vienna, Austria obtained the badge?
SQL: SELECT users.age FROM users INNER JOIN badges ON users.id = badges.userid WHERE users.location = 'Vienna, Austria'
Database: codebase_community
Note: Supporter is the name of badge; adult refers to age BETWEEN 19 AND 65;
Question: How many adults who obtained the badge Supporter?
SQL: SELECT count(users.id) FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.name = 'Supporter' AND users.age BETWEEN 19 AND 65
Database: codebase_community
Note: on 7/19/2010 7:39:08 PM refers to date = '2010-07-19 19:39:08.0';
Question: State the number of views of users who obtained the badge on 7/19/2010 7:39:08 PM.
SQL: SELECT users.views FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.date = '2010-07-19 19:39:08.0'
Database: codebase_community
Note: lowest reputation refers to Min(reputation); user refers to userid;
Question: What are the name of badges that users who have the lowest reputation obtained?
SQL: SELECT badges.name FROM users INNER JOIN badges ON users.id = badges.userid WHERE users.reputation = (SELECT min(reputation) FROM users)
Database: codebase_community
Note: "Sharpie" is the displayname of user; user refers to userid;
Question: State the name of badge that the user whose display name is "Sharpie" obtained.
SQL: SELECT badges.name FROM users INNER JOIN badges ON users.id = badges.userid WHERE users.displayname = 'Sharpie'
Database: codebase_community
Note: "Supporter" is the name of badge;  elders refers to age > 65;
Question: How many elders obtained the "Supporter" badge?
SQL: SELECT count(users.id) FROM users INNER JOIN badges ON users.id = badges.userid WHERE users.age > 65 AND badges.name = 'Supporter'
Database: codebase_community
Note: name of user refers to displayname;
Question: What is the name of user with the ID of 30?
SQL: SELECT displayname FROM users WHERE id = 30
Database: codebase_community
Note: New York refers to location;
Question: How many users were from New York?
SQL: SELECT count(id) FROM users WHERE LOCATION = 'New York'
Database: codebase_community
Note: YEAR(creationdate) = 2010;
Question: How many votes were made in 2010?
SQL: SELECT count(id) FROM votes WHERE strftime('%Y', creationdate) = '2010'
Database: codebase_community
Note: adult refers to user where age BETWEEN 19 and 65;
Question: How many users were adult?
SQL: SELECT count(id) FROM users WHERE age BETWEEN 19 AND 65
Database: codebase_community
Note: users have the highest number of views refer to displayname where MAX(views);
Question: Which users have the highest number of views?
SQL: SELECT id, displayname FROM users WHERE VIEWS = ( SELECT max(VIEWS) FROM users )
Database: codebase_community
Note: DIVidE(count(id where YEAR(creationdate) = 2010), count(id where YEAR(creationdate) = 2011)) FROM votes;
Question: Calculate the ratio of votes in 2010 and 2011.
SQL: SELECT cast(sum(iif(strftime('%Y', creationdate) = '2010', 1, 0)) AS REAL) / sum(iif(strftime('%Y', creationdate) = '2011', 1, 0)) FROM votes
Database: codebase_community
Note: displayname = 'John Salvatier';
Question: What is the name of tags used by John Salvatier's?
SQL: SELECT posts.tags FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posthistory.postid = posts.id WHERE users.displayname = 'John Salvatier'
Database: codebase_community
Note: displayname = 'Daniel Vassallo';
Question: How many posts were created by Daniel Vassallo?
SQL: SELECT count(users.id) FROM users INNER JOIN posthistory ON users.id = posthistory.userid WHERE users.displayname = 'Daniel Vassallo'
Database: codebase_community
Note: displayname = 'Harlan';
Question: How many votes were made by Harlan?
SQL: SELECT count(users.id) FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN votes ON votes.postid = posthistory.postid WHERE users.displayname = 'Harlan'
Database: codebase_community
Note: most answers count refers to MAX(answercount); post by slashnick refers to displayname = 'slashnick';
Question: Which post by slashnick has the most answers count? State the post ID.
SQL: SELECT posthistory.postid FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posthistory.postid = posts.id WHERE users.displayname = 'slashnick' ORDER BY posts.answercount DESC LIMIT 1
Database: codebase_community
Note: Has higher popularity means the post has higher view count ; calculation = MAX(SUM(viewcount)) where displayname = 'Harvey Motulsky' OR displayname = 'Noah Snyder';
Question: Among posts by Harvey Motulsky and Noah Snyder, which one has higher popularity?
SQL: SELECT users.displayname FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posthistory.postid = posts.id WHERE users.displayname = 'Harvey Motulsky' OR users.displayname = 'Noah Snyder' GROUP BY users.displayname ORDER BY sum(posts.viewcount) DESC LIMIT 1
Database: codebase_community
Note: more than 4 votes refer to postid > 4; displayname = 'Matt Parker';
Question: How many posts by Matt Parker have more than 4 votes?
SQL: SELECT count(users.id) FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posthistory.postid = posts.id INNER JOIN votes ON votes.postid = posts.id WHERE users.displayname = 'Matt Parker' GROUP BY posthistory.postid, votes.id HAVING count(votes.id) > 4
Database: codebase_community
Note: Negative comment refers to score < 60; displayname = 'Neil McGuigan';
Question: How many negative comments did Neil McGuigan get in his posts?
SQL: SELECT count(comments.id) FROM users INNER JOIN posts ON users.id = posts.owneruserid INNER JOIN comments ON posts.id = comments.postid WHERE users.displayname = 'Neil McGuigan' AND comments.score < 60
Database: codebase_community
Note: used by Mark Meckes refers to displayname = 'Mark Meckes'; Doen't have comments refers to commentcount = 0;
Question: State all the tags used by Mark Meckes in his posts that doesn't have comments.
SQL: SELECT posts.tags FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posts.id = posthistory.postid WHERE users.displayname = 'Mark Meckes' AND posts.commentcount = 0
Database: codebase_community
Note: name of users refers to displayname; the Organizer badges refer to badges where name = 'Organizer';
Question: List all the name of users that obtained the Organizer Badges.
SQL: SELECT users.displayname FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.`name` = 'Organizer'
Database: codebase_community
Note: DIVidE(count(postid WHERE tagname = 'r')), (count(postid WHERE displayname = 'Community')) as percentage; R language refers to tagname = 'r';
Question: Based on posts posted by Community, calculate the percentage of posts that use the R language.
SQL: SELECT cast(sum(iif(tags.tagname = 'r', 1, 0)) AS REAL) * 100 / count(users.id) FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN tags ON tags.excerptpostid = posthistory.postid WHERE users.displayname = 'Community'
Database: codebase_community
Note: calculation = SUBTRACT(SUM(viewcount where displayname = 'Mornington'), SUM(viewcount where displayname = 'Amos'));
Question: Calculate the difference in view count from post posted by Mornington and view count from posts posted by Amos.
SQL: SELECT sum(iif(users.displayname = 'Mornington', posts.viewcount, 0)) - sum(iif(users.displayname = 'Amos', posts.viewcount, 0)) AS diff FROM users INNER JOIN posthistory ON users.id = posthistory.userid INNER JOIN posts ON posts.id = posthistory.postid
Database: codebase_community
Note: commentator is the name of the badge; year(date) = 2014;
Question: How many users received commentator badges in 2014?
SQL: SELECT count(id) FROM badges WHERE name = 'Commentator' AND strftime('%Y', Date) = '2014'
Database: codebase_community
Note: created on 21st July, 2010 refers to creationdate BETWEEN '2010-07-21 00:00:00' and '2012-07-21 23:59:59';
Question: How many posts were created on 21st July, 2010?
SQL: SELECT count(id) FROM posthistory WHERE date(creationdate) = '2010-07-21'
Database: codebase_community
Note: the highest in views refers to MAX(views);
Question: What are the display names and ages of user who got the highest in views?
SQL: SELECT displayname, age FROM users WHERE VIEWS = ( SELECT max(VIEWS) FROM users )
Database: codebase_community
Note: title = 'Detecting a given face in a database of facial images';
Question: Provide the last edit date and last edit user ID for the post "Detecting a given face in a database of facial images".
SQL: SELECT lasteditdate, lasteditoruserid FROM posts WHERE title = 'Detecting a given face in a database of facial images'
Database: codebase_community
Note: negative comments refer to score < 60;
Question: How many negative comments were given by user ID 13?
SQL: SELECT count(id) FROM comments WHERE userid = 13 AND score < 60
Database: codebase_community
Note: positive comments refer to score > 60;
Question: Describe the post title which got positive comments and display names of the users who posted those comments.
SQL: SELECT posts.title, comments.userdisplayname FROM posts INNER JOIN comments ON comments.postid = comments.id WHERE posts.score > 60
Database: codebase_community
Note: received in 2011 refers to year(date) = 2011;
Question: Provide the badge names received in 2011 for the user whose location is in the North Pole.
SQL: SELECT badges.name FROM users INNER JOIN badges ON users.id = badges.userid WHERE strftime('%Y', badges.date) = '2011' AND users.location = 'North Pole'
Database: codebase_community
Note: favorite count of more than 150 refers to favoritecount > 150;
Question: Provide the users' display names and available website URLs of the post with favorite count of more than 150.
SQL: SELECT users.displayname, users.websiteurl FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE posts.favoritecount > 150
Database: codebase_community
Question: Describe the post history counts and last edit date of the post title "What is the best introductory Bayesian statistics textbook?"
SQL: SELECT posthistory.id, posts.lasteditdate FROM posthistory INNER JOIN posts ON posthistory.postid = posts.id WHERE posts.title = 'What is the best introductory Bayesian statistics textbook?'
Database: codebase_community
Note: Outliers is the name of the badge;
Question: Describe the last accessed date and location of the users who received the outliers badge.
SQL: SELECT users.lastaccessdate, users.location FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.name = 'outliers'