Chinastark/bird_dataset huggingface dataset:
Database: codebase_community
Question: Provide the related post title of "How to tell if something happened in a data set which monitors a value over time".
SQL: SELECT posts.title FROM postlinks INNER JOIN posts ON postlinks.postid = posts.id INNER JOIN posts ON postlinks.relatedpostid = posts.id WHERE posts.title = 'How to tell if something happened in a data set which monitors a value over time'
Database: codebase_community
Note: Samuel refers to userdisplayname; YEAR(creationdate) = 2013 relates to postid; YEAR(date) = 2013 relates to the badge;
Question: List the post IDs and badge names of the user Samuel in 2013.
SQL: SELECT posthistory.postid, badges.name FROM posthistory INNER JOIN badges ON posthistory.userid = badges.userid WHERE posthistory.userdisplayname = 'Samuel' AND strftime('%Y', posthistory.creationdate) = '2013' AND strftime('%Y', badges.date) = '2013'
Database: codebase_community
Note: Higher view count means the post has higher popularity; the most popular post refers to MAX(viewcount);
Question: What is the owner's display name of the most popular post?
SQL: SELECT displayname FROM users WHERE id = ( SELECT owneruserid FROM posts ORDER BY viewcount DESC LIMIT 1 )
Database: codebase_community
Note: user who owned the excerpt post with hypothesis-testing tag refers to owneruserid WHERE tagname = 'hypothesis-testing';
Question: Mention the display name and location of the user who owned the excerpt post with hypothesis-testing tag.
SQL: SELECT users.displayname, users.location FROM tags INNER JOIN posts ON tags.excerptpostid = posts.id INNER JOIN users ON users.id = posts.owneruserid WHERE tags.tagname = 'hypothesis-testing'
Database: codebase_community
Note: title = 'What are principal component scores?';
Question: Write down the related posts titles and link type IDs of the post "What are principal component scores?".
SQL: SELECT posts.title, postlinks.linktypeid FROM posts INNER JOIN postlinks ON posts.id = postlinks.postid INNER JOIN posts ON postlinks.relatedpostid = posts.id WHERE posts.title = 'What are principal component scores?'
Database: codebase_community
Note: If the parent id is not null, the post is the child post; the highest score refers to MAX(score);
Question: Describe the display name of the parent ID for child post with the highest score.
SQL: SELECT displayname FROM users WHERE id = ( SELECT owneruserid FROM posts WHERE parentid IS NOT NULL ORDER BY score DESC LIMIT 1 )
Database: codebase_community
Note: vote type of 8 refers to votetypeid = 8; the highest bounty amount refers to MAX(bountyamount);
Question: Under the vote type of 8, provide the display names and websites URLs of the user who got the highest bounty amount.
SQL: SELECT displayname, websiteurl FROM users WHERE id = ( SELECT userid FROM votes WHERE votetypeid = 8 ORDER BY bountyamount DESC LIMIT 1 )
Database: codebase_community
Note: Higher view count means the post has higher popularity; the highest popularity refers to MAX(viewcount);
Question: What are the titles of the top 5 posts with the highest popularity?
SQL: SELECT title FROM posts ORDER BY viewcount DESC LIMIT 5
Database: codebase_community
Note: post count between 5,000 to 7,000 refers to count BETWEEN 5000 and 7000;
Question: How many tags have post count between 5,000 to 7,000?
SQL: SELECT count(id) FROM tags WHERE COUNT BETWEEN 5000 AND 7000
Database: codebase_community
Note: the most valuable post refers to MAX(favoritecount);
Question: What is the owner user id of the most valuable post?
SQL: SELECT owneruserid FROM posts WHERE favoritecount = ( SELECT max(favoritecount) FROM posts )
Database: codebase_community
Note: How old describes age; the most influential refers to user where MAX(reputation);
Question: How old is the most influential user?
SQL: SELECT age FROM users WHERE reputation = ( SELECT max(reputation) FROM users )
Database: codebase_community
Note: created in 2012 refers YEAR(creationdate) = 2011; bountyamount = 50;
Question: How many posts with votes that were created in 2011 have a bounty of 50?
SQL: SELECT count(posts.id) FROM posts INNER JOIN votes ON posts.id = votes.postid WHERE votes.bountyamount = 50 AND strftime('%Y', votes.creationdate) = '2011'
Database: codebase_community
Note: the youngest user refers to MIN(age);
Question: What is the id of the youngest user?
SQL: SELECT id FROM users WHERE age = ( SELECT min(age) FROM users )
Database: codebase_community
Note: on 2010-07-19 refers to lasactivitydate LIKE '2010-07-19%';
Question: What is the sum of score of the post on 2010-07-19?
SQL: SELECT sum(score) FROM posts WHERE lasactivitydate LIKE '2010-07-19%'
Database: codebase_community
Note: calculation = DIVidE(count(id where YEAR(creationdate) = 2010 and answercount <= 2), 12);
Question: What is the average monthly number of links created in 2010 for posts that have no more than 2 answers?
SQL: SELECT cast(count(postlinks.id) AS REAL) / 12 FROM postlinks INNER JOIN posts ON postlinks.postid = posts.id WHERE posts.answercount <= 2 AND strftime('%Y', postlinks.creationdate) = '2010'
Database: codebase_community
Note: user 1465 refers to userid = 1465; the most valuable post refers to MAX(favoritecount);
Question: Among the posts that were voted by user 1465, what is the id of the most valuable post?
SQL: SELECT posts.id FROM votes INNER JOIN posts ON votes.postid = posts.id WHERE votes.userid = 1465 ORDER BY posts.favoritecount DESC LIMIT 1
Database: codebase_community
Note: the oldest post link refers to MIN(creaiondate);
Question: What is the title of the post with the oldest post link?
SQL: SELECT posts.title FROM posts INNER JOIN postlinks ON postlinks.postid = posts.id ORDER BY posts.creaiondate LIMIT 1
Database: codebase_community
Note: highest amount of badges refers to MAX(count(name));
Question: What is the display name of the user who acquired the highest amount of badges?
SQL: SELECT users.displayname FROM users INNER JOIN badges ON users.id = badges.userid GROUP BY users.displayname ORDER BY count(users.id) DESC LIMIT 1
Database: codebase_community
Note: displayname = 'chl'; cast its first vote refers to MIN(creationdate);
Question: When did 'chl' cast its first vote in a post?
SQL: SELECT votes.creationdate FROM users INNER JOIN votes ON users.id = votes.userid WHERE users.displayname = 'chl' ORDER BY votes.creationdate LIMIT 1
Database: codebase_community
Note: the youngest user refers to MIN(age); first post refers to MIN(creaiondate);
Question: What is the date when the youngest user made his or her first post?
SQL: SELECT posts.creaiondate FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE users.age IS NOT NULL ORDER BY users.age, posts.creaiondate LIMIT 1
Database: codebase_community
Note: Autobiographer is the name of the badge; acquired the first refers to MIN(date);
Question: What is the display name of the user who acquired the first Autobiographer badge?
SQL: SELECT users.displayname FROM users INNER JOIN badges ON users.id = badges.userid WHERE badges.`name` = 'Autobiographer' ORDER BY badges.date LIMIT 1
Database: codebase_community
Note: favorite amount of 4 or more refers to favoritecount >= 4; location = 'United Kingdom';
Question: Among the users located in United Kingdom, how many users whose post have a total favorite amount of 4 or more?
SQL: SELECT count(users.id) FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE users.location = 'United Kingdom' AND posts.favoritecount >= 4
Database: codebase_community
Note: average number of posts voted refers to AVG(postid) FROM votes; the oldest users refer to MAX(age);
Question: What is the average number of posts voted by the oldest users?
SQL: SELECT avg(postid) FROM votes WHERE userid IN ( SELECT id FROM users WHERE age = ( SELECT max(age) FROM users ) )
Database: codebase_community
Note: the highest reputation refers to MAX(reputation);
Question: Who has the highest reputation? Please give the display name.
SQL: SELECT displayname FROM users WHERE reputation = ( SELECT max(reputation) FROM users )
Database: codebase_community
Note: reputations are higher than 2000 refer to reputation > 2000; number of views is higher than 1000 refers to views > 1000;
Question: How many users whose reputations are higher than 2000 and the number of views is higher than 1000?
SQL: SELECT count(id) FROM users WHERE reputation > 2000 AND VIEWS > 1000
Database: codebase_community
Note: adults refer to users where age BETWEEN 19 and 65;
Question: Please list all display names of users who are adults.
SQL: SELECT displayname FROM users WHERE age BETWEEN 19 AND 65
Database: codebase_community
Note: displayname = 'Jay Stevens'; in 2010 refers to YEAR(creationdate) = 2010;
Question: How many posts did Jay Stevens have in 2010?
SQL: SELECT count(users.id) FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE strftime('%Y', posts.creaiondate) = '2010' AND users.displayname = 'Jay Stevens'
Database: codebase_community
Note: displayname = 'Harvey Motulsky'; the most views refer to MAX(viewcount);
Question: Which post by Harvey Motulsky has the most views? Please give the id and title of this post.
SQL: SELECT posts.id, posts.title FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE users.displayname = 'Harvey Motulsky' ORDER BY posts.viewcount DESC LIMIT 1
Database: codebase_community
Note: the highest score refers to MAX(score); owner's name refers to displayname;
Question: Which post has the highest score? Please give its id and title's name.
SQL: SELECT users.id, posts.title FROM users INNER JOIN posts ON users.id = posts.owneruserid ORDER BY posts.score DESC LIMIT 1
Database: codebase_community
Note: displayname = 'Stephen Turner'; average score refers to AVG(score);
Question: What is the average score of Stephen Turner's posts?
SQL: SELECT avg(posts.score) FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE users.displayname = 'Stephen Turner'
Database: codebase_community
Note: had over 20000 views in 2011 refers to viewcount > 20000 where YEAR(creationdate) = 2011;
Question: Please list the users' display names whose posts had over 20000 views in 2011.
SQL: SELECT users.displayname FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE strftime('%Y', posts.creaiondate) = '2011' AND posts.viewcount > 20000
Database: codebase_community
Note: the most valuable post in 2015 refers to MAX(favoritecount) where year(creationdate) = 2010;
Question: Which is the most valuable post in 2010? Please give its id and the owner's display name.
SQL: SELECT posts.owneruserid, users.displayname FROM users INNER JOIN posts ON users.id = posts.owneruserid WHERE strftime('%Y', users.creationdate) = '2010' ORDER BY posts.favoritecount DESC LIMIT 1
Database: codebase_community
Note: percentage = DIVidE(count(id where YEAR(creationdate) = 2011 and reputation > 1000), count(id) ) * 100;
Question: What is the percentage of posts whose owners had a reputation of over 1000 in 2011?
SQL: SELECT cast(sum(iif(strftime('%Y', posts.creaiondate) = '2011' AND users.reputation > 1000, 1, 0)) AS REAL) * 100 / count(users.id) FROM users INNER JOIN posts ON users.id = posts.owneruserid
Database: codebase_community
Note: DIVidE(count(id where age BETWEEN 13 and 18), count(id)) as percentage;
Question: Identify the percentage of teenage users.
SQL: SELECT cast(sum(iif(age BETWEEN 13 AND 18, 1, 0)) AS REAL) * 100 / count(id) FROM users
Database: codebase_community
Note: total views refer to viewcount; name the user refers to displayname; post 'Computer Game Datasets' refers to text = 'Computer Game Datasets';
Question: Identify the total views on the post 'Computer Game Datasets'. Name the user who posted it last time.
SQL: SELECT posts.viewcount, users.displayname FROM posthistory INNER JOIN posts ON posthistory.postid = posts.id INNER JOIN users ON posts.lasteditoruserid = users.id WHERE posthistory.text = 'Computer Game Datasets'
Database: codebase_community
Note: views above average refer to viewcount > AVG(viewcount);
Question: Identify the total number of posts with views above average.
SQL: SELECT id FROM posts WHERE viewcount > ( SELECT avg(viewcount) FROM posts )
Database: codebase_community
Note: the highest score refers to MAX(score);
Question: How many comments were added to the post with the highest score?
SQL: SELECT count(comments.id) FROM posts INNER JOIN comments ON posts.id = comments.postid GROUP BY posts.id ORDER BY sum(posts.score) DESC LIMIT 1
Database: codebase_community
Note: have been viewed over 35000 times refers to viewcount > 35000; received no comments refers to commentcount = 0;
Question: Identify the number of posts that have been viewed over 35000 times but have received no comments from other users.
SQL: SELECT count(id) FROM posts WHERE viewcount > 35000 AND commentcount = 0
Database: codebase_community
Note: last to edit refers to MAX(lasteditdate);
Question: Identify the display name and location of the user, who was the last to edit the post with ID 183.
SQL: SELECT users.displayname, users.location FROM posts INNER JOIN users ON posts.owneruserid = users.id WHERE posts.id = 183 ORDER BY posts.lasteditdate DESC LIMIT 1
Database: codebase_community
Note: the latest badge refers to name FROM badges where MAX(date);
Question: Identify the latest badge awarded to the user with the display name Emmett.
SQL: SELECT badges.name FROM badges INNER JOIN users ON badges.userid = users.id WHERE users.displayname = 'Emmett' ORDER BY badges.date DESC LIMIT 1
Database: codebase_community
Note: adult users refer to age BETWEEN 19 and 65; over 5000 upvotes refer to upvotes > 5000;
Question: Identify the number of adult users who have cast over 5000 upvotes.
SQL: SELECT count(id) FROM users WHERE age BETWEEN 19 AND 65 AND upvotes > 5000
Database: codebase_community
Note: SUBTRACT(date from stats_badges, creationdate) where displayname = 'Zolomon';
Question: How long did it take the user, known by his or her display name 'Zolomon' to get the badge? Count from the date the user's account was created.
SQL: SELECT badges.date - users.creationdate FROM badges INNER JOIN users ON badges.userid = users.id WHERE users.displayname = 'Zolomon'
Database: codebase_community
Note: the latest created user account refers to MAX(creationdate);
Question: Identify the number of posts and comments left by the user, who has the latest created user account.
SQL: SELECT count(posts.id) FROM users INNER JOIN posts ON users.id = posts.owneruserid INNER JOIN comments ON comments.postid = posts.id ORDER BY users.creationdate DESC LIMIT 1
Database: codebase_community
Note: the latest comment refers to MAX(creationdate);
Question: Provide the text of the latest 10 comments to the post with the title 'Analysing wind data with R' and the display name of the user who left it.
SQL: SELECT comments.text, users.displayname FROM users INNER JOIN posts ON users.id = posts.owneruserid INNER JOIN comments ON posts.id = comments.postid WHERE posts.title = 'Analysing wind data with R' ORDER BY users.creationdate DESC LIMIT 10
Database: codebase_community
Note: Citizen Patrol' is the name of the badge;
Question: How many users were awarded with 'Citizen Patrol' badge?
SQL: SELECT count(id) FROM badges WHERE `name` = 'Citizen Patrol'
Database: codebase_community
Note: tag specified as 'careers' refers to tagname = 'careers';
Question: Count the number of posts with a tag specified as 'careers'.
SQL: SELECT count(id) FROM tags WHERE tagname = 'careers'
Database: codebase_community
Question: What is the reputation and view count of the user, who is known by his or her display name 'Jarrod Dixon'?
SQL: SELECT reputation, VIEWS FROM users WHERE displayname = 'Jarrod Dixon'
Database: codebase_community
Question: How many comments and answers were left by the users on the post with the title 'Clustering 1D data'?
SQL: SELECT commentcount, answercount FROM posts WHERE title = 'Clustering 1D data'
Database: codebase_community
Note: displayname = 'IrishStat'; when create his or her account refers to creationdate;
Question: When did the user known as 'IrishStat' create his or her account?
SQL: SELECT creationdate FROM users WHERE displayname = 'IrishStat'
Database: codebase_community
Note: bounty amount over 30 refers to bountyamount >= 30;
Question: Identify the number of posts that offer a bounty amount over 30.
SQL: SELECT count(id) FROM votes WHERE bountyamount >= 30
Database: codebase_community
Note: The higher reputation the user has the more influence; percentage = DIVidE(count(stats_posts.id where score > 50 and MAX(reputation))), count(stats_posts.id where MAX(reputation));
Question: Among all the posts posted by the most influential user, identify the percentage with a score above 50.
SQL: SELECT cast(sum(CASE WHEN posts.score > 50 THEN 1 ELSE 0 END) AS REAL) * 100 / count(users.id) FROM users users INNER JOIN posts posts ON users.id = posts.owneruserid INNER JOIN ( SELECT max(reputation) AS max_reputation FROM users ) t3 ON users.reputation = t3.max_reputation
Database: codebase_community
Note: score less than 20 refers to score < 20;
Question: How many posts have a score less than 20?
SQL: SELECT count(id) FROM posts WHERE score < 20
Database: codebase_community
Note: id below 15 refers to id < 15; have 20 count of posts and below refers to count <= 20;
Question: Among the tags with tag ID below 15, how many of them have 20 count of posts and below?
SQL: SELECT count(id) FROM tags WHERE COUNT <= 20 AND id < 15
Database: codebase_community
Note: tag named sample refers to tagname = 'sample';
Question: What is the excerpt post ID and wiki post ID of the tag named sample?
SQL: SELECT excerptpostid, wikipostid FROM tags WHERE tagname = 'sample'
Database: codebase_community
Note: text = 'fine, you win :)';
Question: Give the user's reputation and up vote number of the user that commented "fine, you win :)".
SQL: SELECT users.reputation, users.upvotes FROM comments INNER JOIN users ON comments.userid = users.id WHERE comments.text = 'fine, you win :)'
Database: codebase_community
Note: about linear regression refers to title contains 'linear regression';
Question: Give the texts commented on the post about linear regression.
SQL: SELECT comments.text FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE posts.title LIKE '%linear regression%'
Database: codebase_community
Note: views ranging from 100 to 150 refers to viewcount BETWEEN 100 and 150; comment with the highest score refers to text where MAX(score);
Question: Among the posts with views ranging from 100 to 150, what is the comment with the highest score?
SQL: SELECT Text FROM comments WHERE postid IN ( SELECT id FROM posts WHERE viewcount BETWEEN 100 AND 150 ) ORDER BY score DESC LIMIT 1
Database: codebase_community
Note: commented with webiste refers to the value contains 'http://';
Question: List the creation date and age of the user that commented with webiste.
SQL: SELECT users.creationdate, users.age FROM comments INNER JOIN users ON comments.userid = users.id WHERE comments.text LIKE '%http://%'
Database: codebase_community
Note: view count lower than 5 refers to viewcount < 5;
Question: In comments with 0 score, how many of the posts have view count lower than 5?
SQL: SELECT count(comments.id) FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE posts.viewcount < 5 AND posts.score = 0
Database: codebase_community
Note: in posts with 1 comment refers to commentcount = 1;
Question: In posts with 1 comment, how many of the comments have 0 score?
SQL: SELECT count(comments.id) FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE posts.commentcount = 1 AND posts.score = 0
Database: codebase_community
Question: Among products comments with 0 score, what is the total number of users ages 40 years old?
SQL: SELECT count(DISTINCT comments.id) FROM comments INNER JOIN users ON comments.userid = users.id WHERE comments.score = 0 AND users.age = 40
Database: codebase_community
Note: title = 'Group differences on a five point Likert item';
Question: What is the post ID and the comments commented in the post titled by "Group differences on a five point Likert item"?
SQL: SELECT posts.id, comments.text FROM comments INNER JOIN posts ON comments.postid = posts.id WHERE posts.title = 'Group differences on a five point Likert item'
Database: codebase_community
Note: commented "R is also lazy evaluated." refers to text of the comment;
Question: What is the up vote number of the user that commented "R is also lazy evaluated."?
SQL: SELECT users.upvotes FROM comments INNER JOIN users ON comments.userid = users.id WHERE comments.text = 'R is also lazy evaluated.'
Database: codebase_community
Note: comments refer to text; username of Harvey Motulsky refers to displayname = 'Harvey Motulsky';
Question: List the comments commented by the user with a username of Harvey Motulsky.
SQL: SELECT comments.text FROM comments INNER JOIN users ON comments.userid = users.id WHERE users.displayname = 'Harvey Motulsky'
Database: codebase_community
Note: downvotes = 0; score BETWEEN 1 and 5;
Question: In comments with score between 1 to 5, list down the display names of the users with 0 down votes.
SQL: SELECT users.displayname FROM comments INNER JOIN users ON comments.userid = users.id WHERE comments.score BETWEEN 1 AND 5 AND users.downvotes = 0
Database: codebase_community
Note: percentage = DIVidE(count(userid where upvotes = 0 and score BETWEEN 5 and 10))*100, (count(userid where score BETWEEN 5 and 10));
Question: Among the comments with scores between 5 to 10, what is the percentage of the users with 0 up votes?
SQL: SELECT cast(sum(iif(users.upvotes = 0, 1, 0)) AS REAL) * 100/ count(users.id) AS per FROM users INNER JOIN comments ON users.id = comments.userid WHERE comments.score BETWEEN 5 AND 10
Database: superhero
Note: 3-D Man refers to superhero_name = '3-D Man'; superpowers refers to power_name;
Question: Please list all the superpowers of 3-D Man.
SQL: SELECT superpower.power_name FROM superhero INNER JOIN hero_power ON superhero.id = hero_power.hero_id INNER JOIN superpower ON hero_power.power_id = superpower.id WHERE superhero.superhero_name = '3-D Man'
Database: superhero
Note: super power of "Super Strength" refers to power_name = 'Super Strength';
Question: How many superheroes have the super power of "Super Strength"?
SQL: SELECT count(hero_power.hero_id) FROM hero_power INNER JOIN superpower ON hero_power.power_id = superpower.id WHERE superpower.power_name = 'Super Strength'
Database: superhero
Note: super power of "Super Strength" refers to power_name = 'Super Strength'; a height of over 200cm refers to height_cm > 200;
Question: Among the superheroes with the super power of "Super Strength", how many of them have a height of over 200cm?
SQL: SELECT count(superhero.id) FROM superhero INNER JOIN hero_power ON superhero.id = hero_power.hero_id INNER JOIN superpower ON hero_power.power_id = superpower.id WHERE superpower.power_name = 'Super Strength' AND superhero.height_cm > 200
Database: superhero
Note: 15 super powers refers to COUNT(full_name) > 15;
Question: Please list the full names of all the superheroes with over 15 super powers.
SQL: SELECT DISTINCT superhero.full_name FROM superhero INNER JOIN hero_power ON superhero.id = hero_power.hero_id GROUP BY superhero.full_name HAVING count(hero_power.power_id) > 15
Database: superhero
Note: blue eyes refers to colour = 'Blue' and eye_colour_id = colour.id;
Question: How many superheroes have blue eyes?
SQL: SELECT count(superhero.id) FROM superhero INNER JOIN colour ON superhero.eye_colour_id = colour.id WHERE colour.colour = 'Blue'
Database: superhero
Note: Apocalypse refers to superhero_name = 'Apocalypse'; colour of skin refers to colour where skin_colour_id = colour.id;
Question: What is the colour of Apocalypse's skin?
SQL: SELECT colour.colour FROM superhero INNER JOIN colour ON superhero.skin_colour_id = colour.id WHERE superhero.superhero_name = 'Apocalypse'