birdsql/bird_sql_dev_20251106 huggingface dataset:
Database: codebase_community
Question: Which users have used only one post history type across all posts having at least 1000 views?
Evidence: having at least 1000 view refers to ViewCount > = 1000; user refers to UserId
SQL:
SELECT T2.UserId FROM users AS T1 INNER JOIN postHistory AS T2 ON T1.Id = T2.UserId INNER JOIN posts AS T3 ON T2.PostId = T3.Id WHERE T3.ViewCount >= 1000 GROUP BY T2.UserId HAVING COUNT(DISTINCT T2.PostHistoryTypeId) = 1
Database: codebase_community
Question: Which user has posted the most comments? List out all the user's badge.
Evidence: user with the most comments refers to UserId where Max(Count(Id)
SQL:
WITH TopComment AS (SELECT UserId FROM comments GROUP BY UserId ORDER BY COUNT(*) DESC LIMIT 1) SELECT B.Name FROM badges B JOIN TopComment TC ON B.UserId = TC.UserId;
Database: codebase_community
Question: How many users from India have the teacher badges?
Evidence: 'India' is the Location; 'Teacher' is the Name of badge
SQL:
SELECT COUNT(T1.Id)
FROM badges AS T1
INNER JOIN users AS T2 ON T1.UserId = T2.Id
WHERE T2.Location = 'India' AND T1.Name = 'Teacher';
Database: codebase_community
Question: What is the percentage difference of student badges given during 2010 and 2011?
Evidence: 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)
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 T1.PostHistoryTypeId,
       (SELECT COUNT(DISTINCT UserId) FROM comments WHERE PostId = 3720) AS NumberOfUsers
FROM postHistory AS T1
WHERE T1.PostId = 3720;
Database: codebase_community
Question: List out all post that are related to post ID 61217 and what is the popularity of this post?
Evidence: post related refers to RelatedPostId; popularity refers to ViewCount
SQL:
SELECT DISTINCT p.Id, p.Title, p.ViewCount
FROM postLinks AS pl
INNER JOIN posts AS p ON p.Id = pl.RelatedPostId
WHERE pl.PostId = 61217;
Database: codebase_community
Question: What is the score and the link type ID for post ID 395?
SQL:
SELECT T1.Score, T2.LinkTypeId FROM posts AS T1 INNER JOIN postLinks AS T2 ON T1.Id = T2.PostId WHERE T2.PostId = 395
Database: codebase_community
Question: List out all post ID with score more than 60 and list out all the user ID that created these post.
Evidence: score more than 60 refers to Score > 60
SQL:
SELECT PostId, UserId FROM postHistory WHERE PostId IN ( SELECT Id FROM posts WHERE Score > 60 )
Database: codebase_community
Question: What is the sum of favourite count gained by user ID 686 in 2011?
Evidence: in 2011 refers to year (CreatinDate) = 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
Question: What is the average of the up votes and the average user age for users creating more than 10 posts?
Evidence: 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))
SQL:
SELECT AVG(T1.UpVotes), AVG(T1.Age) FROM users AS T1 INNER JOIN ( SELECT OwnerUserId, COUNT(*) AS post_count FROM posts GROUP BY OwnerUserId HAVING post_count > 10) AS T2 ON T1.Id = T2.OwnerUserId
Database: codebase_community
Question: How many users obtained the "Announcer" badge?
Evidence: "Announcer" is the Name of badge; user refers to UserId
SQL:
SELECT COUNT(id) FROM badges WHERE Name = 'Announcer'
Database: codebase_community
Question: List out the name of badges that users obtained on 7/19/2010 7:39:08 PM.
Evidence: on 7/19/2010 7:39:08 PM refers to Date = '2010-07-19 19:39:08.0'
SQL:
SELECT DISTINCT Name FROM badges WHERE Date = '2010-07-19 19:39:08.0'
Database: codebase_community
Question: How many positive comments are there on the list?
Evidence: Positive comment refers to score > 60
SQL:
SELECT COUNT(id) FROM comments WHERE score > 60
Database: codebase_community
Question: State the detailed content of the comment which was created on 7/19/2010 7:25:47 PM.
Evidence: 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'
SQL:
SELECT Text FROM comments WHERE CreationDate = '2010-07-19 19:16:14.0'
Database: codebase_community
Question: How many posts have a score of 10 on the list?
Evidence: score of 10 refers to Score = 10; post refers to Id
SQL:
SELECT COUNT(id) FROM posts WHERE Score = 10
Database: codebase_community
Question: What are the name of badge that users who have the highest reputation obtained?
Evidence: highest reputation refers to Max(Reputation); user refers to UserId
SQL:
SELECT DISTINCT T2.name FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.Reputation = (SELECT MAX(Reputation) FROM users);
Database: codebase_community
Question: Mention the reputation of users who had obtained the badge on 7/19/2010 7:39:08 PM.
Evidence: on 7/19/2010 7:39:08 PM refers to Date = '2010-07-19 19:39:08.0'
SQL:
SELECT T1.Reputation FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T2.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 T2.Name FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.DisplayName = 'Pierre'
Database: codebase_community
Question: List out the dates that users who are located in Rochester, NY obtained their badges?
Evidence: "Rochester, NY" is the Location of user; user refers to UserId
SQL:
SELECT T2.Date FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.Location = 'Rochester, NY'
Database: codebase_community
Question: Among the users who obtained the "Teacher" badge, calculate their percentage of users
Evidence: "Teacher" is the Name of badge;  
percentage = (teacher badge users)/(total users)
SQL:
SELECT CAST(COUNT(T1.Id) AS REAL) * 100 / (SELECT COUNT(Id) FROM users) FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T2.Name = 'Teacher'
Database: codebase_community
Question: Among the users who obtained the "Organizer" badges, calculate the percentage of users who are teenagers.
Evidence: teenager refers to Age BETWEEN 13 AND 18; percentage = Divide (Count(UserId where Age BETWEEN 13 AND 18), Count(UserId)) *100
SQL:
SELECT CAST(SUM(IIF(T2.Age BETWEEN 13 AND 18, 1, 0)) AS REAL) * 100 / COUNT(T1.Id) FROM badges AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T1.`Name` = 'Organizer'
Database: codebase_community
Question: What is the comment's rating score of the post which was created on 7/19/2010 7:19:56 PM
Evidence: created on 7/19/2010 7:19:56 PM refers to CreationDate = '2010-07-19 19:19:56.0'
SQL:
SELECT T1.Score FROM comments AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T1.CreationDate = '2010-07-19 19:19:56.0'
Database: codebase_community
Question: What is the detailed content of the comment of the post which was created on 7/19/2010 7:37:33 PM?
Evidence: 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'
SQL:
SELECT T1.Text FROM comments AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T1.CreationDate = '2010-07-19 19:37:33.0'
Database: codebase_community
Question: List the ages of users located in Vienna, Austria who have obtained badges.
Evidence: Vienna, Austria is the Location
SQL:
SELECT T1.Age FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.Location = 'Vienna, Austria' AND T1.Age IS NOT NULL
Database: codebase_community
Question: How many adults who obtained the badge Supporter?
Evidence: Supporter is the Name of badge; adult refers to Age BETWEEN 19 AND 65
SQL:
SELECT COUNT(T1.Id) FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T2.Name = 'Supporter' AND T1.Age BETWEEN 19 AND 65
Database: codebase_community
Question: State the number of views of users who obtained the badge on 7/19/2010 7:39:08 PM.
Evidence: on 7/19/2010 7:39:08 PM refers to Date = '2010-07-19 19:39:08.0'
SQL:
SELECT T1.Views FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T2.Date = '2010-07-19 19:39:08.0'
Database: codebase_community
Question: What are the name of badges that users who have the lowest reputation obtained?
Evidence: lowest reputation refers to the smallest reputation value among all users;
SQL:
SELECT T2.Name FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.Reputation = (SELECT MIN(Reputation) FROM users)
Database: codebase_community
Question: State the name of badge that the user whose display name is "Sharpie" obtained.
Evidence: "Sharpie" is the DisplayName of user; user refers to UserId
SQL:
SELECT DISTINCT T2.Name FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.DisplayName = 'Sharpie'
Database: codebase_community
Question: How many elders obtained the "Supporter" badge?
Evidence: "Supporter" is the Name of badge;  elders refers to Age > 65
SQL:
SELECT COUNT(T1.Id) FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T1.Age > 65 AND T2.Name = 'Supporter'
Database: codebase_community
Question: What is the name of user with the ID of 30?
Evidence: name of user refers to DisplayName;
SQL:
SELECT DisplayName FROM users WHERE Id = 30
Database: codebase_community
Question: How many users were from New York?
Evidence: New York refers to Location;
SQL:
SELECT COUNT(Id) FROM users WHERE Location = 'New York'
Database: codebase_community
Question: How many votes were made in 2010?
SQL:
SELECT COUNT(id) FROM votes WHERE STRFTIME('%Y', CreationDate) = '2010'
Database: codebase_community
Question: How many users were adult?
Evidence: adult refers to user where Age BETWEEN 19 and 65;
SQL:
SELECT COUNT(id) FROM users WHERE Age BETWEEN 19 AND 65
Database: codebase_community
Question: Which users have the highest number of views?
Evidence: Users with the highest number of views are those whose total view count is the largest
SQL:
SELECT Id, DisplayName FROM users WHERE Views = ( SELECT MAX(Views) FROM users )
Database: codebase_community
Question: Calculate the ratio of votes in 2010 and 2011.
Evidence: ratio = DIVIDE(the number of id in votes table where year(CreationDate) = 2010, the number of id in votes table where year(CreationDate) = 2011)
SQL:
SELECT CAST(SUM(IIF(STRFTIME('%Y', CreationDate) = '2010', 1, 0)) AS REAL) / NULLIF(SUM(IIF(STRFTIME('%Y', CreationDate) = '2011', 1, 0)), 0) FROM votes
Database: codebase_community
Question: What is the name of tags used by John Salvatier's?
Evidence: DisplayName = 'John Salvatier';
SQL:
SELECT T3.Tags FROM users AS T1 INNER JOIN postHistory AS T2 ON T1.Id = T2.UserId INNER JOIN posts AS T3 ON T2.PostId = T3.Id WHERE T1.DisplayName = 'John Salvatier'
Database: codebase_community
Question: How many posts were created by Daniel Vassallo?
Evidence: DisplayName = 'Daniel Vassallo';
SQL:
SELECT COUNT(T2.Id) FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T1.DisplayName = 'Daniel Vassallo'
Database: codebase_community
Question: How many votes were made by Harlan?
Evidence: DisplayName = 'Harlan';
SQL:
SELECT COUNT(T1.Id) FROM users AS T1 INNER JOIN postHistory AS T2 ON T1.Id = T2.UserId INNER JOIN votes AS T3 ON T3.PostId = T2.PostId WHERE T1.DisplayName = 'Harlan'
Database: codebase_community
Question: Which post by slashnick has the most answers count? State the post ID.
Evidence: most answers count refers to MAX(AnswerCount); post by slashnick refers to DisplayName = 'slashnick';
SQL:
SELECT T3.Id 
FROM users AS T1 
INNER JOIN posts AS T3 ON T1.Id = T3.OwnerUserId 
WHERE T1.DisplayName = 'slashnick' 
ORDER BY T3.AnswerCount DESC 
LIMIT 1
Database: codebase_community
Question: Among posts by Harvey Motulsky and Noah Snyder, which one has higher popularity?
Evidence: Has higher popularity means the post has higher view count ; calculation = MAX(SUM(ViewCount)) where DisplayName = 'Harvey Motulsky' OR DisplayName = 'Noah Snyder';
SQL:
SELECT T1.DisplayName FROM users AS T1 INNER JOIN postHistory AS T2 ON T1.Id = T2.UserId INNER JOIN posts AS T3 ON T2.PostId = T3.Id WHERE T1.DisplayName = 'Harvey Motulsky' OR T1.DisplayName = 'Noah Snyder' GROUP BY T1.DisplayName ORDER BY SUM(T3.ViewCount) DESC LIMIT 1
Database: codebase_community
Question: How many posts by Matt Parker have more than 4 votes?
Evidence: more than 4 votes refer to PostId > 4; DisplayName = 'Matt Parker';
SQL:
SELECT COUNT(*) FROM ( SELECT T2.Id FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId INNER JOIN votes AS T3 ON T3.PostId = T2.Id WHERE T1.DisplayName = 'Matt Parker' GROUP BY T2.Id HAVING COUNT(T3.Id) > 4);
Database: codebase_community
Question: How many negative comments did Neil McGuigan get in his posts?
Evidence: Negative comment refers to score < 60; DisplayName = 'Neil McGuigan';
SQL:
SELECT COUNT(T3.Id) FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId INNER JOIN comments AS T3 ON T2.Id = T3.PostId WHERE T1.DisplayName = 'Neil McGuigan' AND T3.Score < 60
Database: codebase_community
Question: State all the tags used by Mark Meckes in his posts that doesn't have comments.
Evidence: used by Mark Meckes refers to DisplayName = 'Mark Meckes'; Doen't have comments refers to CommentCount = 0;
SQL:
SELECT DISTINCT T3.Tags FROM users AS T1 INNER JOIN postHistory AS T2 ON T1.Id = T2.UserId INNER JOIN posts AS T3 ON T3.Id = T2.PostId WHERE T1.DisplayName = 'Mark Meckes' AND T3.CommentCount = 0 AND T3.Tags IS NOT NULL
Database: codebase_community
Question: List all the name of users that obtained the Organizer Badges.
Evidence: name of users refers to DisplayName; the Organizer Badges refer to badges where Name = 'Organizer';
SQL:
SELECT T1.DisplayName FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T2.`Name` = 'Organizer'
Database: codebase_community
Question: Based on posts posted by Community, calculate the percentage of posts that use the R language.
Evidence: Community refers to DisplayName = 'Community'; R language posts are those with tag 'r'; percentage is calculated as posts with R tag divided by total posts by Community
SQL:
SELECT CAST(SUM(CASE WHEN T1.Tags LIKE '%<r>%' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Id) FROM posts AS T1 INNER JOIN users AS T2 ON T1.OwnerUserId = T2.Id WHERE T2.DisplayName = 'Community'
Database: codebase_community
Question: Calculate the difference in view count of posts posted by Mornington and view count of posts posted by Amos.
Evidence: Difference refers to subtraction; Mornington and Amos are user display names.
SQL:
SELECT SUM(CASE WHEN T1.DisplayName = 'Mornington' THEN T2.ViewCount ELSE 0 END) - SUM(CASE WHEN T1.DisplayName = 'Amos' THEN T2.ViewCount ELSE 0 END) FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T1.DisplayName IN ('Mornington', 'Amos')
Database: codebase_community
Question: How many users received commentator badges in 2014?
Evidence: Commentator is the name of the badge; year(Date) = 2014;
SQL:
SELECT COUNT(DISTINCT UserId) FROM badges WHERE Name = 'Commentator' AND STRFTIME('%Y', Date) = '2014'
Database: codebase_community
Question: How many posts were created on 21st July, 2010?
Evidence: created on 21st July, 2010 refers to CreationDate = '2010-07-21'
SQL:
SELECT COUNT(id) FROM postHistory WHERE date(CreationDate) = '2010-07-21'
Database: codebase_community
Question: What are the display names and ages of user who got the highest in views?
Evidence: the highest in views refers to MAX(Views);
SQL:
SELECT DisplayName, Age FROM users WHERE Views = ( SELECT MAX(Views) FROM users )
Database: codebase_community
Question: Provide the last edit date and last edit user ID for the post "Detecting a given face in a database of facial images".
Evidence: Title = '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
Question: How many negative comments were given by user ID 13?
Evidence: negative comments refer to Score < 60;
SQL:
SELECT COUNT(Id) FROM comments WHERE UserId = 13 AND Score < 60
Database: codebase_community
Question: Describe the post title which got positive comments and display names of the users who posted those comments.
Evidence: positive comments refer to Score > 60;
SQL:
SELECT DISTINCT T1.Title, T2.UserDisplayName
FROM posts AS T1
INNER JOIN comments AS T2 ON T1.Id = T2.PostId
WHERE T2.Score > 60 AND T1.Title IS NOT NULL AND T2.UserDisplayName IS NOT NULL;
Database: codebase_community
Question: Provide the badge names received in 2011 for the user whose location is in the North Pole.
Evidence: received in 2011 refers to year(Date) = 2011;
SQL:
SELECT T2.Name FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE STRFTIME('%Y', T2.Date) = '2011' AND T1.Location = 'North Pole'
Database: codebase_community
Question: Provide the users' display names and available website URLs of the post with favorite count of more than 150.
Evidence: favorite count of more than 150 refers to FavoriteCount > 150;
SQL:
SELECT T1.DisplayName, T1.WebsiteUrl FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T2.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 COUNT(T1.Id), T2.LastEditDate FROM postHistory AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T2.Title = 'What is the best introductory Bayesian statistics textbook?'
Database: codebase_community
Question: Describe the last accessed date and location of the users who received the outliers badge.
Evidence: Outliers is the name of the badge;
SQL:
SELECT T1.LastAccessDate, T1.Location FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId WHERE T2.Name = 'outliers'
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 T3.Title FROM postLinks AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id INNER JOIN posts AS T3 ON T1.RelatedPostId = T3.Id WHERE T2.Title = 'How to tell if something happened in a data set which monitors a value over time'
Database: codebase_community
Question: List the post IDs and badge names of the user Samuel in 2013.
Evidence: Samuel refers to UserDisplayName; YEAR(CreationDate) = 2013 relates to PostId; YEAR(Date) = 2013 relates to the badge;
SQL:
SELECT T1.PostId, T2.Name FROM postHistory AS T1 INNER JOIN badges AS T2 ON T1.UserId = T2.UserId WHERE T1.UserDisplayName = 'Samuel' AND STRFTIME('%Y', T1.CreationDate) = '2013' AND STRFTIME('%Y', T2.`Date`) = '2013'
Database: codebase_community
Question: What is the owner's display name of the most popular post?
Evidence: Higher view count means the post has higher popularity; the most popular post refers to MAX(ViewCount);
SQL:
SELECT DisplayName FROM users WHERE Id = ( SELECT OwnerUserId FROM posts ORDER BY ViewCount DESC LIMIT 1 )
Database: codebase_community
Question: Mention the display name and location of the user who owned the excerpt post with hypothesis-testing tag.
SQL:
SELECT T3.DisplayName, T3.Location FROM tags AS T1 INNER JOIN posts AS T2 ON T1.ExcerptPostId = T2.Id INNER JOIN users AS T3 ON T3.Id = T2.OwnerUserId WHERE T1.TagName = 'hypothesis-testing'
Database: codebase_community
Question: Write down the related posts titles and link type IDs of the post "What are principal component scores?".
Evidence: Title = 'What are principal component scores?';
SQL:
SELECT T3.Title, T2.LinkTypeId FROM posts AS T1 INNER JOIN postLinks AS T2 ON T1.Id = T2.PostId INNER JOIN posts AS T3 ON T2.RelatedPostId = T3.Id WHERE T1.Title = 'What are principal component scores?'
Database: codebase_community
Question: Describe the display name of the parent ID for child post with the highest score.
Evidence: If the parent id is not null, the post is the child post; the highest score refers to MAX(Score);
SQL:
SELECT DisplayName FROM posts AS T1 JOIN posts AS T2 ON T2.ID = T1.ParentId LEFT JOIN users AS T3 ON T3.Id = T2.OwnerUserId WHERE T1.ParentId IS NOT NULL ORDER BY T1.Score DESC LIMIT 1
Database: codebase_community
Question: Under the vote type of 8, provide the display names and websites URLs of the user who got the highest bounty amount.
Evidence: vote type of 8 refers to VoteTypeId = 8; the highest bounty amount refers to MAX(BountyAmount);
SQL:
SELECT DisplayName, WebsiteUrl FROM users WHERE Id = ( SELECT UserId FROM votes WHERE VoteTypeId = 8 ORDER BY BountyAmount DESC LIMIT 1 )
Database: codebase_community
Question: What are the titles of the top 5 posts with the highest popularity?
Evidence: Higher view count means the post has higher popularity; "top 5 posts with the highest popularity" refers to the first 5 posts sorted by ViewCount in descending order (supplemented by Id in ascending order for stable results when ViewCount is the same).
SQL:
SELECT Title FROM posts ORDER BY ViewCount DESC, Id ASC LIMIT 5;
Database: codebase_community
Question: How many tags have post count between 5,000 to 7,000?
Evidence: post count between 5,000 to 7,000 refers to Count BETWEEN 5000 and 7000;
SQL:
SELECT COUNT(Id) FROM tags WHERE Count BETWEEN 5000 AND 7000
Database: codebase_community
Question: What is the owner user id of the most valuable post?
Evidence: the most valuable post refers to the post with most favorite count;
SQL:
SELECT OwnerUserId FROM posts WHERE FavoriteCount = ( SELECT MAX(FavoriteCount) FROM posts )
Database: codebase_community
Question: How old is the most influential user?
Evidence: How old describes age; the most influential refers to user where MAX(Reputation);
SQL:
SELECT Age FROM users WHERE Reputation = ( SELECT MAX(Reputation) FROM users )
Database: codebase_community
Question: How many posts with votes that were created in 2011 have a bounty of 50?
Evidence: created in 2011 refers to the year when the votes were created; bounty of 50 refers to a bounty amount of 50
SQL:
SELECT COUNT(T1.Id) FROM posts AS T1 INNER JOIN votes AS T2 ON T1.Id = T2.PostId WHERE T2.BountyAmount = 50 AND STRFTIME('%Y', T2.CreationDate) = '2011'
Database: codebase_community
Question: What is the id of the youngest user?
Evidence: the youngest user refers to MIN(Age);
SQL:
SELECT Id FROM users WHERE Age = ( SELECT MIN(Age) FROM users )
Database: codebase_community
Question: What is the sum of score of the post on 2010-07-19?
Evidence: on 2010-07-19 refers to LasActivityDate LIKE '2010-07-19%';
SQL:
SELECT SUM(Score) FROM posts WHERE LasActivityDate LIKE '2010-07-19%'
Database: codebase_community
Question: What is the average monthly number of links created in 2010 for posts that have no more than 2 answers?
Evidence: [Remove Evidence]
SQL:
SELECT CAST(COUNT(T1.Id) AS REAL) / 12 FROM postLinks AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T2.AnswerCount <= 2 AND STRFTIME('%Y', T1.CreationDate) = '2010'
Database: codebase_community
Question: Among the posts that were voted by user 1465, what is the id of the most valuable post?
Evidence: user 1465 refers to UserId = 1465; the most valuable post refers to MAX(FavoriteCount);
SQL:
SELECT T2.Id FROM votes AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T1.UserId = 1465 ORDER BY T2.FavoriteCount DESC LIMIT 1
Database: codebase_community
Question: What is the title of the post with the oldest post link?
Evidence: the oldest post link refers to MIN(CreaionDate);
SQL:
SELECT T1.Title FROM posts AS T1 INNER JOIN postLinks AS T2 ON T2.PostId = T1.Id ORDER BY T1.CreaionDate LIMIT 1
Database: codebase_community
Question: What is the display name of the user who acquired the highest amount of badges?
Evidence: highest amount of badges refers to counting all badges received by each user and finding the maximum count
SQL:
SELECT T1.DisplayName FROM users AS T1 INNER JOIN badges AS T2 ON T1.Id = T2.UserId GROUP BY T1.DisplayName ORDER BY COUNT(T2.Id) DESC LIMIT 1
Database: codebase_community
Question: When did 'chl' cast its first vote in a post?
Evidence: DisplayName = 'chl'; cast its first vote refers to MIN(CreationDate);
SQL:
SELECT T2.CreationDate FROM users AS T1 INNER JOIN votes AS T2 ON T1.Id = T2.UserId WHERE T1.DisplayName = 'chl' ORDER BY T2.CreationDate LIMIT 1
Database: codebase_community
Question: What is the date when the youngest user made his or her first post?
Evidence: the youngest user refers to MIN(Age); first post refers to MIN(CreaionDate);
SQL:
SELECT T2.CreaionDate FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T1.Age IS NOT NULL ORDER BY T1.Age, T2.CreaionDate LIMIT 1
Database: codebase_community
Question: What is the display name of the user who acquired the first Autobiographer badge?
Evidence: Autobiographer is the name of the badge; acquired the first refers to MIN(Date);
SQL:
SELECT T1.DisplayName 
FROM users AS T1 
INNER JOIN badges AS T2 ON T1.Id = T2.UserId 
WHERE T2.`Name` = 'Autobiographer' 
ORDER BY T2.Date ASC, T2.Id ASC 
LIMIT 1;
Database: codebase_community
Question: Among the users located in United Kingdom, how many users whose post have a total favorite amount of 4 or more?
Evidence: favorite amount of 4 or more refers to FavoriteCount > = 4; Location = 'United Kingdom';
SQL:
SELECT COUNT(T1.Id) FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T1.Location = 'United Kingdom' AND T2.FavoriteCount >= 4
Database: codebase_community
Question: What is the average number of posts voted by the oldest users?
Evidence: average number of posts voted refers to AVG(PostId) FROM votes; the oldest users refer to MAX(Age);
SQL:
SELECT AVG(PostId) FROM votes WHERE UserId IN ( SELECT Id FROM users WHERE Age = ( SELECT MAX(Age) FROM users ) )
Database: codebase_community
Question: Who has the highest reputation? Please give the display name.
Evidence: the highest reputation refers to MAX(Reputation);
SQL:
SELECT DisplayName FROM users WHERE Reputation = ( SELECT MAX(Reputation) FROM users )
Database: codebase_community
Question: How many users whose reputations are higher than 2000 and the number of views is higher than 1000?
Evidence: reputations are higher than 2000 refer to Reputation > 2000; number of views is higher than 1000 refers to Views > 1000;
SQL:
SELECT COUNT(id) FROM users WHERE Reputation > 2000 AND Views > 1000
Database: codebase_community
Question: Please list all display names of users who are adults.
Evidence: adults refer to users where Age BETWEEN 19 and 65;
SQL:
SELECT DisplayName FROM users WHERE Age BETWEEN 19 AND 65
Database: codebase_community
Question: How many posts did Jay Stevens have in 2010?
Evidence: DisplayName = 'Jay Stevens'; in 2010 refers to YEAR(CreationDate) = 2010;
SQL:
SELECT COUNT(T1.Id) FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE STRFTIME('%Y', T2.CreaionDate) = '2010' AND T1.DisplayName = 'Jay Stevens'
Database: codebase_community
Question: Which post by Harvey Motulsky has the most views? Please give the id and title of this post.
Evidence: DisplayName = 'Harvey Motulsky'; the most views refer to MAX(ViewCount);
SQL:
SELECT T2.Id, T2.Title FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T1.DisplayName = 'Harvey Motulsky' ORDER BY T2.ViewCount DESC LIMIT 1
Database: codebase_community
Question: Which post has the highest score? Please give its id and title's name.
Evidence: the highest score refers to MAX(Score); owner's name refers to DisplayName;
SQL:
SELECT T1.Id, T2.Title FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId ORDER BY T2.Score DESC LIMIT 1
Database: codebase_community
Question: What is the average score of Stephen Turner's posts?
Evidence: DisplayName = 'Stephen Turner'; average score refers to AVG(Score);
SQL:
SELECT AVG(T2.Score) FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE T1.DisplayName = 'Stephen Turner'
Database: codebase_community
Question: Please list the users' display names whose posts had over 20000 views in 2011.
Evidence: had over 20000 views in 2011 refers to ViewCount > 20000 where YEAR(CreationDate) = 2011;
SQL:
SELECT T1.DisplayName FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE STRFTIME('%Y', T2.CreaionDate) = '2011' AND T2.ViewCount > 20000
Database: codebase_community
Question: Which is the most valuable post in 2010? Please give its id and the owner's display name.
Evidence: the most valuable post in 2010 refers to MAX(FavoriteCount) where year(CreationDate) = 2010;
SQL:
SELECT T2.OwnerUserId, T1.DisplayName FROM users AS T1 INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId WHERE STRFTIME('%Y', T2.CreaionDate) = '2010' ORDER BY T2.FavoriteCount DESC LIMIT 1
Database: codebase_community
Question: What is the percentage of posts whose owners had a reputation of over 1000 in 2011?
Evidence: percentage = DIVIDE(COUNT(Id where YEAR(CreationDate) = 2011 and Reputation > 1000), COUNT(Id) ) * 100;
SQL:
SELECT 
    (SUM(IIF(STRFTIME('%Y', T2.CreaionDate) = '2011' AND T1.Reputation > 1000, 1, 0)) * 100.0) 
    / COUNT(IIF(STRFTIME('%Y', T2.CreaionDate) = '2011', 1, NULL))
FROM users AS T1 
INNER JOIN posts AS T2 ON T1.Id = T2.OwnerUserId
Database: codebase_community
Question: Identify the percentage of teenage users.
Evidence: teenage users are defined as those with age between 13 and 18 years old;
SQL:
SELECT CAST(SUM(IIF(Age BETWEEN 13 AND 18, 1, 0)) AS REAL) * 100 / COUNT(Id) FROM users
Database: codebase_community
Question: Identify the total views on the post 'Computer Game Datasets'. Name the user who posted it last time.
Evidence: total views refer to ViewCount; Name the user refers to DisplayName; post 'Computer Game Datasets' refers to Text = 'Computer Game Datasets';
SQL:
SELECT T2.ViewCount, T3.DisplayName FROM postHistory AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id INNER JOIN users AS T3 ON T2.LastEditorUserId = T3.Id WHERE T1.Text = 'Computer Game Datasets'
Database: codebase_community
Question: Identify the total number of posts with views above average.
Evidence: views above average refer to ViewCount > AVG(ViewCount);
SQL:
SELECT COUNT(*) 
FROM posts 
WHERE ViewCount > (SELECT AVG(ViewCount) FROM posts)
Database: codebase_community
Question: How many comments were added to the post with the highest score?
Evidence: the highest score refers to MAX(Score);
SQL:
SELECT T1.CommentCount
FROM posts T1
WHERE T1.Score = (SELECT MAX(Score) FROM posts);
Database: codebase_community
Question: Identify the number of posts that have been viewed over 35000 times but have received no comments from other users.
Evidence: have been viewed over 35000 times refers to ViewCount > 35000; received no comments refers to CommentCount = 0;
SQL:
SELECT COUNT(Id) FROM posts WHERE ViewCount > 35000 AND CommentCount = 0
Database: codebase_community
Question: Identify the display name and location of the user, who was the last to edit the post with ID 183.
Evidence: last to edit refers to MAX(LastEditDate);
SQL:
SELECT T2.DisplayName, T2.Location FROM posts AS T1 INNER JOIN users AS T2 ON T1.OwnerUserId = T2.Id WHERE T1.Id = 183 ORDER BY T1.LastEditDate DESC LIMIT 1
Database: codebase_community
Question: Identify the latest badge awarded to the user with the display name Emmett.
Evidence: the latest badge refers to Name FROM badges where MAX(Date);
SQL:
SELECT T1.Name FROM badges AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T2.DisplayName = 'Emmett' ORDER BY T1.Date DESC LIMIT 1
Database: codebase_community
Question: Identify the number of adult users who have cast over 5000 upvotes.
Evidence: adult users refer to Age BETWEEN 19 and 65; over 5000 upvotes refer to UpVotes > 5000;
SQL:
SELECT COUNT(Id) FROM users WHERE Age BETWEEN 19 AND 65 AND UpVotes > 5000
Database: codebase_community
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.
Evidence: SUBTRACT(Date from stats_badges, CreationDate) where DisplayName = 'Zolomon';
SQL:
SELECT T1.Date - T2.CreationDate FROM badges AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T2.DisplayName = 'Zolomon'
Database: codebase_community
Question: Identify the number of posts and comments left by the user, who has the latest created user account.
Evidence: the latest created user account refers to MAX(CreationDate);
SQL:
SELECT COUNT(DISTINCT T2.Id), COUNT(DISTINCT T3.Id) FROM users AS T1 LEFT JOIN posts AS T2 ON T2.OwnerUserId = T1.Id LEFT JOIN comments AS T3 ON T3.UserID = T1.Id ORDER BY T1.CreationDate DESC LIMIT 1
Database: codebase_community
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.
Evidence: the latest comment refers to MAX(CreationDate);
SQL:
SELECT T3.Text, T1.DisplayName FROM posts AS T2 INNER JOIN comments AS T3 ON T3.PostID = T2.Id LEFT JOIN users AS T1 ON T1.Id = T3.UserId WHERE T2.Title = 'Analysing wind data with R' ORDER BY T3.CreationDate DESC LIMIT 10
Database: codebase_community
Question: How many users were awarded with 'Citizen Patrol' badge?
Evidence: 'Citizen Patrol' is the name of the badge;
SQL:
SELECT COUNT(DISTINCT UserId) FROM badges WHERE Name = 'Citizen Patrol'
Database: codebase_community
Question: Count the number of posts with a tag specified as 'careers'.
Evidence: tag specified as 'careers' refers to TagName = '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
Question: When did the user known as 'IrishStat' create his or her account?
Evidence: DisplayName = 'IrishStat'; when create his or her account refers to CreationDate;
SQL:
SELECT CreationDate FROM users WHERE DisplayName = 'IrishStat'
Database: codebase_community
Question: Identify the number of posts that offer a bounty amount over 30.
Evidence: bounty amount over 30 refers to BountyAmount > = 30;
SQL:
SELECT COUNT(id) FROM votes WHERE BountyAmount >= 30;
Database: codebase_community
Question: Among all the posts posted by the most influential user, identify the percentage with a score above 50.
Evidence: The most influential user is defined as the user with the highest reputation; the percentage is calculated based on the proportion of posts with a score above 50 among all posts by that user;
SQL:
SELECT CAST(SUM(CASE WHEN T2.Score > 50 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Id) FROM users T1 INNER JOIN posts T2 ON T1.Id = T2.OwnerUserId INNER JOIN ( SELECT MAX(Reputation) AS max_reputation FROM users ) T3 ON T1.Reputation = T3.max_reputation
Database: codebase_community
Question: How many posts have a score less than 20?
Evidence: score less than 20 refers to Score < 20;
SQL:
SELECT COUNT(id) FROM posts WHERE Score < 20
Database: codebase_community
Question: Among the tags with tag ID below 15, how many of them have 20 count of posts and below?
Evidence: ID below 15 refers to Id < 15; have 20 count of posts and below refers to Count < = 20;
SQL:
SELECT COUNT(id) FROM tags WHERE Count <= 20 AND Id < 15
Database: codebase_community
Question: What is the excerpt post ID and wiki post ID of the tag named sample?
Evidence: tag named sample refers to TagName = 'sample';
SQL:
SELECT ExcerptPostId, WikiPostId FROM tags WHERE TagName = 'sample'
Database: codebase_community
Question: Give the user's reputation and up vote number of the user that commented "fine, you win :)".
Evidence: Text = 'fine, you win :)'
SQL:
SELECT T2.Reputation, T2.UpVotes FROM comments AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T1.Text = 'fine, you win :)'
Database: codebase_community
Question: Give the texts commented on the post about linear regression.
Evidence: about linear regression refers to Title contains 'linear regression'
SQL:
SELECT T1.Text FROM comments AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T2.Title LIKE '%linear regression%'
Database: codebase_community
Question: Among the posts with views ranging from 100 to 150, what is the comment with the highest score?
Evidence: comment with the highest score refers to Text where MAX(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
Question: List the creation date and age of the user that commented with webiste.
Evidence: commented with webiste refers to the value contains 'http://'
SQL:
SELECT T2.CreationDate, T2.Age FROM comments AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T1.text LIKE '%http://%'
Database: codebase_community
Question: In comments with 0 score, how many of the posts have view count lower than 5?
Evidence: view count lower than 5 refers to ViewCount < 5;
SQL:
SELECT COUNT(DISTINCT T2.Id) FROM comments AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T2.ViewCount < 5 AND T1.Score = 0
Database: codebase_community
Question: In posts with 1 comment, how many of the comments have 0 score?
Evidence: in posts with 1 comment refers to CommentCount = 1;
SQL:
SELECT COUNT(T1.id)
FROM comments AS T1
INNER JOIN posts AS T2 ON T1.PostId = T2.Id
WHERE T2.CommentCount = 1 AND T1.Score = 0;
Database: codebase_community
Question: Among product comments with 0 score, what is the total number of users aged 40 years old?
SQL:
SELECT COUNT(DISTINCT T2.Id)
FROM comments AS T1
INNER JOIN users AS T2 ON T1.UserId = T2.Id
WHERE T1.Score = 0 AND T2.Age = 40;
Database: codebase_community
Question: What is the post ID and the comments commented in the post titled by "Group differences on a five point Likert item"?
Evidence: Title = 'Group differences on a five point Likert item';
SQL:
SELECT T2.Id, T1.Text FROM comments AS T1 INNER JOIN posts AS T2 ON T1.PostId = T2.Id WHERE T2.Title = 'Group differences on a five point Likert item'
Database: codebase_community
Question: What is the up vote number of the user that commented "R is also lazy evaluated."?
Evidence: commented "R is also lazy evaluated." refers to Text of the comment;
SQL:
SELECT T2.UpVotes FROM comments AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T1.Text = 'R is also lazy evaluated.'
Database: codebase_community
Question: List the comments commented by the user with a username of Harvey Motulsky.
Evidence: comments refer to Text; username of Harvey Motulsky refers to DisplayName = 'Harvey Motulsky';
SQL:
SELECT T1.Text FROM comments AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T2.DisplayName = 'Harvey Motulsky'
Database: codebase_community
Question: In comments with score between 1 to 5, list down the display names of the users with 0 down votes.
Evidence: DownVotes = 0; Score BETWEEN 1 and 5
SQL:
SELECT DISTINCT T2.DisplayName FROM comments AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T1.Score BETWEEN 1 AND 5 AND T2.DownVotes = 0
Database: codebase_community
Question: Among the comments with scores between 5 to 10, what is the percentage of the users with 0 up votes?
Evidence: percentage = DIVIDE(COUNT(UserId where UpVotes = 0 and Score BETWEEN 5 and 10))*100, (COUNT(UserId where Score BETWEEN 5 and 10));
SQL:
SELECT CAST(COUNT(DISTINCT CASE WHEN T1.UpVotes = 0 THEN T1.Id END) AS REAL) * 100/ COUNT(DISTINCT T1.Id) AS per FROM users AS T1 INNER JOIN comments AS T2 ON T1.Id = T2.UserId WHERE T2.Score BETWEEN 5 AND 10
Database: superhero
Question: Please list all the superpowers of 3-D Man.
Evidence: 3-D Man refers to superhero_name = '3-D Man'; superpowers refers to power_name
SQL:
SELECT T3.power_name FROM superhero AS T1 INNER JOIN hero_power AS T2 ON T1.id = T2.hero_id INNER JOIN superpower AS T3 ON T2.power_id = T3.id WHERE T1.superhero_name = '3-D Man'
Database: superhero
Question: How many superheroes have the super power of "Super Strength"?
Evidence: super power of "Super Strength" refers to power_name = 'Super Strength'
SQL:
SELECT COUNT(T1.hero_id) FROM hero_power AS T1 INNER JOIN superpower AS T2 ON T1.power_id = T2.id WHERE T2.power_name = 'Super Strength'
Database: superhero
Question: Among the superheroes with the super power of "Super Strength", how many of them have a height of over 200cm?
Evidence: 'Super Strength' refers to power_name
SQL:
SELECT COUNT(T1.id) FROM superhero AS T1 INNER JOIN hero_power AS T2 ON T1.id = T2.hero_id INNER JOIN superpower AS T3 ON T2.power_id = T3.id WHERE T3.power_name = 'Super Strength' AND T1.height_cm > 200
Database: superhero
Question: Please list the full names of all the superheroes with over 15 super powers.
Evidence: 15 super powers refers to COUNT(full_name) > 15
SQL:
SELECT DISTINCT T1.full_name FROM superhero AS T1 INNER JOIN hero_power AS T2 ON T1.id = T2.hero_id GROUP BY T1.full_name HAVING COUNT(T2.power_id) > 15
Database: superhero
Question: How many superheroes have blue eyes?
Evidence: blue eyes refers to colour = 'Blue' and eye_colour_id = colour.id;
SQL:
SELECT COUNT(T1.id)
FROM superhero AS T1
INNER JOIN colour AS T2 ON T1.eye_colour_id = T2.id
WHERE T2.colour = 'Blue';
Database: superhero
Question: What is the colour of Apocalypse's skin?
Evidence: Apocalypse refers to superhero_name = 'Apocalypse'; colour of skin refers to colour where skin_colour_id = colour.id
SQL:
SELECT T2.colour FROM superhero AS T1 INNER JOIN colour AS T2 ON T1.skin_colour_id = T2.id WHERE T1.superhero_name = 'Apocalypse'
Database: superhero
Question: Among the superheroes with blue eyes, how many of them have the super power of "Agility"?
Evidence: blue eyes refers to the eye colour = 'Blue' in the colour table; super power of "Agility" refers to power_name = 'Agility'
SQL:
SELECT COUNT(T1.id) FROM superhero AS T1 INNER JOIN hero_power AS T2 ON T1.id = T2.hero_id INNER JOIN superpower AS T3 ON T2.power_id = T3.id INNER JOIN colour AS T4 ON T1.eye_colour_id = T4.id WHERE T3.power_name = 'Agility' AND T4.colour = 'Blue'
Database: superhero
Question: Please list the superhero names of all the superheroes that have blue eyes and blond hair.
Evidence: blue eyes refers to colour = 'Blue' and eye_colour_id = colour.id; blond hair refers to colour = 'Blond' and hair_colour_id = colour.id;
SQL:
SELECT T1.superhero_name FROM superhero AS T1 INNER JOIN colour AS T2 ON T1.eye_colour_id = T2.id INNER JOIN colour AS T3 ON T1.hair_colour_id = T3.id WHERE T2.colour = 'Blue' AND T3.colour = 'Blond'
Database: superhero
Question: How many superheroes are published by Marvel Comics?
Evidence: published by Marvel Comics refers to publisher_name = 'Marvel Comics'
SQL:
SELECT COUNT(T1.id) FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T2.publisher_name = 'Marvel Comics'
Database: superhero
Question: Rank heroes published by Marvel Comics by their height in descending order.
Evidence: published by Marvel Comics refers to publisher_name = 'Marvel Comics'
SQL:
SELECT superhero_name, height_cm, RANK() OVER (ORDER BY height_cm DESC) AS HeightRank FROM superhero INNER JOIN publisher ON superhero.publisher_id = publisher.id WHERE publisher.publisher_name = 'Marvel Comics'
Database: superhero
Question: Who is the publisher of Sauron?
Evidence: the publisher refers to publisher_name; Sauron refers to superhero_name = 'Sauron'
SQL:
SELECT T2.publisher_name FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T1.superhero_name = 'Sauron'
Database: superhero
Question: Rank superheroes from Marvel Comics by their eye color popularity, starting with the most common color.
Evidence: the superheroes from Marvel Comics refers to publisher_name = 'Marvel Comics'; most common color refers to COUNT(superhero.id) DESC;
SQL:
SELECT colour.colour AS EyeColor, COUNT(superhero.id) AS Count, RANK() OVER (ORDER BY COUNT(superhero.id) DESC) AS PopularityRank FROM superhero INNER JOIN colour ON superhero.eye_colour_id = colour.id INNER JOIN publisher ON superhero.publisher_id = publisher.id WHERE publisher.publisher_name = 'Marvel Comics' GROUP BY colour.colour
Database: superhero
Question: What is the average height of the superheroes from Marvel Comics?
Evidence: superheroes from Marvel Comics refers to publisher_name = 'Marvel Comics'; average height of the superheroes refers to AVG(height_cm)
SQL:
SELECT AVG(T1.height_cm) FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T2.publisher_name = 'Marvel Comics'
Database: superhero
Question: List the superheroes from Marvel Comics who have the super power of 'Super Strength'.
Evidence: the superheroes from Marvel Comics refers to publisher_name = 'Marvel Comics'; super power of "Super Strength" refers to power_name = 'Super Strength';
SQL:
SELECT superhero_name FROM superhero AS T1 WHERE EXISTS (SELECT 1 FROM hero_power AS T2 INNER JOIN superpower AS T3 ON T2.power_id = T3.id WHERE T3.power_name = 'Super Strength' AND T1.id = T2.hero_id)AND EXISTS (SELECT 1 FROM publisher AS T4 WHERE T4.publisher_name = 'Marvel Comics' AND T1.publisher_id = T4.id)
Database: superhero
Question: How many superheroes did DC Comics publish?
Evidence: superheroes that DC Comics published refers to publisher_name = 'DC Comics'
SQL:
SELECT COUNT(T1.id) FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T2.publisher_name = 'DC Comics'
Database: superhero
Question: Which publisher published the slowest superhero?
Evidence: the slowest superhero refers to attribute_name = 'Speed' where MIN(attribute_value); publisher refers to publisher_name
SQL:
SELECT T2.publisher_name FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id INNER JOIN hero_attribute AS T3 ON T1.id = T3.hero_id INNER JOIN attribute AS T4 ON T3.attribute_id = T4.id WHERE T4.attribute_name = 'Speed' ORDER BY T3.attribute_value LIMIT 1
Database: superhero
Question: How many gold-eyed superheroes did Marvel Comics publish?
Evidence: gold-eyed refers to colour = 'Gold' where eye_colour_id = colour.id; superheroes that Marvel Comics published refers to publisher_name = 'Marvel Comics'
SQL:
SELECT COUNT(T1.id) FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id INNER JOIN colour AS T3 ON T1.eye_colour_id = T3.id WHERE T2.publisher_name = 'Marvel Comics' AND T3.colour = 'Gold'
Database: superhero
Question: What is the publisher's name of Blue Beetle II?
SQL:
SELECT T2.publisher_name FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T1.superhero_name = 'Blue Beetle II'
Database: superhero
Question: How many superheroes with blonde hair are there?
Evidence: superheroes with blonde hair refers to colour = 'Blond' where hair_colour_id = colour.id
SQL:
SELECT COUNT(T1.id) FROM superhero AS T1 INNER JOIN colour AS T2 ON T1.hair_colour_id = T2.id WHERE T2.colour = 'Blond'
Database: superhero
Question: Who is the dumbest superhero?
Evidence: The dumbest superhero is the one with the lowest intelligence attribute value.
SQL:
SELECT T1.superhero_name 
FROM superhero AS T1 
INNER JOIN hero_attribute AS T2 ON T1.id = T2.hero_id 
INNER JOIN attribute AS T3 ON T2.attribute_id = T3.id 
WHERE T3.attribute_name = 'Intelligence' 
ORDER BY T2.attribute_value ASC, T1.id ASC 
LIMIT 1
Database: superhero
Question: What is Copycat's race?
Evidence: Copycat is the superhero_name;
SQL:
SELECT T2.race FROM superhero AS T1 INNER JOIN race AS T2 ON T1.race_id = T2.id WHERE T1.superhero_name = 'Copycat'
Database: superhero
Question: Which superheroes have a durability attribute value of less than 50?
Evidence: durability of less than 50 refers to attribute_name = 'Durability' AND attribute_value < 50
SQL:
SELECT superhero_name FROM superhero AS T1 WHERE EXISTS (SELECT 1 FROM hero_attribute AS T2 INNER JOIN attribute AS T3 ON T2.attribute_id = T3.id WHERE T3.attribute_name = 'Durability' AND T2.attribute_value < 50 AND T1.id = T2.hero_id)