context
stringlengths
28
393
answer
stringlengths
17
532
question
stringlengths
5
112
CREATE TABLE weather (mean_sea_level_pressure_inches INTEGER, date VARCHAR)
SELECT date FROM weather WHERE mean_sea_level_pressure_inches BETWEEN 30.3 AND 31
哪些日子的平均海平面气压在30.3到31之间?
CREATE TABLE weather (min_temperature_f VARCHAR, max_temperature_f VARCHAR, date VARCHAR)
SELECT date, max_temperature_f - min_temperature_f FROM weather ORDER BY max_temperature_f - min_temperature_f LIMIT 1
找出最大温度与最小温度之差最小的一天。并报告差异。
CREATE TABLE weather (min_temperature_f VARCHAR, max_temperature_f VARCHAR, date VARCHAR)
SELECT date, max_temperature_f - min_temperature_f FROM weather ORDER BY max_temperature_f - min_temperature_f LIMIT 1
哪些天具有最小的温度范围,那个范围是什么?
CREATE TABLE station (name VARCHAR, id VARCHAR), CREATE TABLE status (bikes_available INTEGER, station_id VARCHAR)
SELECT DISTINCT T1.id, T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available > 12
有超过12辆可用自行车的车站的ID和名称是什么?
CREATE TABLE station (name VARCHAR, id VARCHAR), CREATE TABLE status (bikes_available INTEGER, station_id VARCHAR)
SELECT DISTINCT T1.id, T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available > 12
有超过12辆可用自行车的车站有哪些不同的ID和名称?
CREATE TABLE weather (mean_humidity INTEGER, zip_code VARCHAR), CREATE TABLE trip (mean_humidity INTEGER, zip_code VARCHAR)
SELECT zip_code FROM weather GROUP BY zip_code HAVING AVG(mean_humidity) < 70 INTERSECT SELECT zip_code FROM trip GROUP BY zip_code HAVING COUNT(*) >= 100
给我平均湿度低于70,至少有100个路线的地区邮编。
CREATE TABLE weather (mean_humidity INTEGER, zip_code VARCHAR), CREATE TABLE trip (mean_humidity INTEGER, zip_code VARCHAR)
SELECT zip_code FROM weather GROUP BY zip_code HAVING AVG(mean_humidity) < 70 INTERSECT SELECT zip_code FROM trip GROUP BY zip_code HAVING COUNT(*) >= 100
平均湿度低于70并且至少有100次旅行的邮政编码是什么?
CREATE TABLE station (end_station_name VARCHAR, name VARCHAR, city VARCHAR), CREATE TABLE trip (end_station_name VARCHAR, name VARCHAR, city VARCHAR)
SELECT name FROM station WHERE city = "西安" EXCEPT SELECT end_station_name FROM trip GROUP BY end_station_name HAVING COUNT(*) > 100
位于“西安”市但没能成为100次以上路线的终点的车站叫什么名字?
CREATE TABLE station (end_station_name VARCHAR, name VARCHAR, city VARCHAR), CREATE TABLE trip (end_station_name VARCHAR, name VARCHAR, city VARCHAR)
SELECT name FROM station WHERE city = "西安" EXCEPT SELECT end_station_name FROM trip GROUP BY end_station_name HAVING COUNT(*) > 100
位于“西安”但从未成为路线终点的车站叫什么名字?
CREATE TABLE station (city VARCHAR, id VARCHAR), CREATE TABLE trip (id VARCHAR, end_station_id VARCHAR)
SELECT COUNT(*) FROM station AS T1, trip AS T2, station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "重庆" AND T3.city = "西安"
从“重庆”出发到“西安”有多少路线?
CREATE TABLE station (city VARCHAR, id VARCHAR), CREATE TABLE trip (id VARCHAR, end_station_id VARCHAR)
SELECT COUNT(*) FROM station AS T1, trip AS T2, station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "重庆" AND T3.city = "西安"
从“重庆”的一个车站到“西安”的一个车站,总共有多少次旅行?
CREATE TABLE station (lat INTEGER, long INTEGER, id VARCHAR), CREATE TABLE trip (start_station_id VARCHAR)
SELECT AVG(T1.lat), AVG(T1.long) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id
所有路线起点的平均纬度和经度是多少?
CREATE TABLE station (lat INTEGER, long INTEGER, id VARCHAR), CREATE TABLE trip (start_station_id VARCHAR)
SELECT AVG(T1.lat), AVG(T1.long) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id
所有出发站的平均纬度和经度是多少?
CREATE TABLE book (Id VARCHAR)
SELECT COUNT(*) FROM book
有多少本书?
CREATE TABLE book (Writer VARCHAR)
SELECT Writer FROM book ORDER BY Writer ASC
按字母顺序列出书的作者。
CREATE TABLE book (Title VARCHAR, Issues VARCHAR)
SELECT Title FROM book ORDER BY Issues ASC
按出版升序排列,列出书名。
CREATE TABLE book (Writer VARCHAR, Title VARCHAR)
SELECT Title FROM book WHERE Writer <> "钱钟书"
作者不是“钱钟书”的书名是什么?
CREATE TABLE book (Title VARCHAR, Issues VARCHAR)
SELECT Title, Issues FROM book
书的题目和出版是什么?
CREATE TABLE publication (Price VARCHAR, Publication_Date VARCHAR)
SELECT Publication_Date FROM publication ORDER BY Price DESC
按价格降序排列的出版物日期是什么?
CREATE TABLE publication (Publisher VARCHAR, Price INTEGER)
SELECT DISTINCT Publisher FROM publication WHERE Price > 5000000
哪些不同出版商有格高于5000000的出版物?
CREATE TABLE publication (Price VARCHAR, Publisher VARCHAR)
SELECT Publisher FROM publication ORDER BY Price DESC LIMIT 1
列出出版物价格最高的出版商。
CREATE TABLE publication (Price VARCHAR, Publication_Date VARCHAR)
SELECT Publication_Date FROM publication ORDER BY Price ASC LIMIT 3
列出3个最低价格的出版物的出版日期。
CREATE TABLE book (Title VARCHAR, Book_ID VARCHAR), CREATE TABLE publication (Book_ID VARCHAR, Publication_Date VARCHAR)
SELECT T1.Title, T2.Publication_Date FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID
显示图书的书名和出版日期。
CREATE TABLE book (Writer VARCHAR, Book_ID VARCHAR), CREATE TABLE publication (Book_ID VARCHAR, Price INTEGER)
SELECT T1.Writer FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID WHERE T2.Price > 4000000
显示已经出版的一本价格超过4000000的书的作家。
CREATE TABLE book (Title VARCHAR, Book_ID VARCHAR), CREATE TABLE publication (Price VARCHAR, Book_ID VARCHAR)
SELECT T1.Title FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID ORDER BY T2.Price DESC
按出版物价格的顺序显示书名。
CREATE TABLE publication (Publisher VARCHAR)
SELECT Publisher FROM publication GROUP BY Publisher HAVING COUNT(*) > 1
显示有不止一个出版物的出版商。
CREATE TABLE publication (Publisher VARCHAR)
SELECT Publisher, COUNT(*) FROM publication GROUP BY Publisher
展示不同的出版商以及他们出版的出版物数量。
CREATE TABLE publication (Publication_Date VARCHAR)
SELECT Publication_Date FROM publication GROUP BY Publication_Date ORDER BY COUNT(*) DESC LIMIT 1
请显示最常见的出版日期。
CREATE TABLE book (Writer VARCHAR)
SELECT Writer FROM book GROUP BY Writer HAVING COUNT(*) > 1
列出那些写过不止一本书的作家。
CREATE TABLE book (Title VARCHAR, Book_ID VARCHAR), CREATE TABLE publication (Title VARCHAR, Book_ID VARCHAR)
SELECT Title FROM book WHERE NOT Book_ID IN (SELECT Book_ID FROM publication)
列出未出版的书名。
CREATE TABLE publication (Publisher VARCHAR, Price INTEGER)
SELECT Publisher FROM publication WHERE Price > 10000000 INTERSECT SELECT Publisher FROM publication WHERE Price < 5000000
显示价格高于10000000和价格低于50000000的出版物的出版商。
CREATE TABLE publication (Publication_Date VARCHAR)
SELECT COUNT(DISTINCT Publication_Date) FROM publication
不同出版日期的出版物数量是多少?
CREATE TABLE publication (Publication_Date VARCHAR)
SELECT COUNT(DISTINCT Publication_Date) FROM publication
我们的记录中有多少种不同的出版日期?
CREATE TABLE publication (Price VARCHAR, Publisher VARCHAR)
SELECT Price FROM publication WHERE Publisher = "文学" OR Publisher = "机械"
显示出版商是“文学”或“机械”的出版物价格。
CREATE TABLE actor (Id VARCHAR)
SELECT COUNT(*) FROM actor
那儿有多少演员?
CREATE TABLE actor (Id VARCHAR)
SELECT COUNT(*) FROM actor
统计演员的数量。
CREATE TABLE actor (Name VARCHAR)
SELECT Name FROM actor ORDER BY Name ASC
按照升序字母顺序列出演员的名字。
CREATE TABLE actor (Name VARCHAR)
SELECT Name FROM actor ORDER BY Name ASC
演员的名字是什么,按字母顺序排列?
CREATE TABLE actor (Character VARCHAR, Duration VARCHAR)
SELECT Character, Duration FROM actor
演员的角色和持续时间是什么?
CREATE TABLE actor (Character VARCHAR, Duration VARCHAR)
SELECT Character, Duration FROM actor
返回每个演员的角色和持续时间。
CREATE TABLE actor (Age VARCHAR, Name VARCHAR)
SELECT Name FROM actor WHERE Age <> 20
列出年龄不是20岁的演员的名字。
CREATE TABLE actor (Age VARCHAR, Name VARCHAR)
SELECT Name FROM actor WHERE Age <> 20
不是20岁的演员的名字是什么?
CREATE TABLE actor (age VARCHAR, Character VARCHAR)
SELECT Character FROM actor ORDER BY age DESC
按照年龄降序,演员的角色是什么?
CREATE TABLE actor (age VARCHAR, Character VARCHAR)
SELECT Character FROM actor ORDER BY age DESC
返回演员的角色,按年龄降序排序。
CREATE TABLE actor (Age VARCHAR, Duration VARCHAR)
SELECT Duration FROM actor ORDER BY Age DESC LIMIT 1
最老演员的持续时间是多少?
CREATE TABLE actor (Age VARCHAR, Duration VARCHAR)
SELECT Duration FROM actor ORDER BY Age DESC LIMIT 1
返回最大年龄的演员的持续时间。
CREATE TABLE musical (Nominee VARCHAR, Name VARCHAR)
SELECT Name FROM musical WHERE Nominee = "梁朝伟"
提名“梁朝伟”的音乐剧名称是什么?
CREATE TABLE musical (Nominee VARCHAR, Name VARCHAR)
SELECT Name FROM musical WHERE Nominee = "梁朝伟"
返回有提名“梁朝伟”的音乐剧名称。
CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)
SELECT DISTINCT Nominee FROM musical WHERE Award <> "金鸡奖"
除了“金鸡奖”之外,还有哪些音乐剧的不同提名呢?
CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)
SELECT DISTINCT Nominee FROM musical WHERE Award <> "金鸡奖"
返回奖项不是“金鸡奖”的音乐剧的不同提名。
CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T1.Name, T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID
显示演员姓名和音乐剧名称。
CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T1.Name, T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID
演员和他们出演的音乐剧的名字是什么?
CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID WHERE T2.Name = "歌剧魅影"
显示以“歌剧魅影”为名字的音乐剧中的演员的名字。
CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID WHERE T2.Name = "歌剧魅影"
音乐剧“歌剧魅影”的演员叫什么名字?
CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Year VARCHAR)
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC
以出演的音乐剧获奖的年份降序排列,显示演员姓名。
CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Year VARCHAR)
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC
按出演的音乐剧获奖年份降序排列,演员姓名是什么?
CREATE TABLE actor (Musical_ID VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T2.Name, COUNT(*) FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID
显示音乐剧的名称和在音乐剧中出现的演员的数目。
CREATE TABLE actor (Musical_ID VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T2.Name, COUNT(*) FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID
每个音乐剧中有多少演员?
CREATE TABLE actor (Musical_ID VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID HAVING COUNT(*) >= 3
显示至少有三个演员的音乐剧名称。
CREATE TABLE actor (Musical_ID VARCHAR), CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)
SELECT T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID HAVING COUNT(*) >= 3
有3个或更多演员的音乐剧名称是什么?
CREATE TABLE musical (Nominee VARCHAR)
SELECT Nominee, COUNT(*) FROM musical GROUP BY Nominee
显示不同的被提名者和他们提名的音乐剧的数量。
CREATE TABLE musical (Nominee VARCHAR)
SELECT Nominee, COUNT(*) FROM musical GROUP BY Nominee
每个被提名者有多少音乐剧被提名?
CREATE TABLE musical (Nominee VARCHAR)
SELECT Nominee FROM musical GROUP BY Nominee ORDER BY COUNT(*) DESC LIMIT 1
请显示被提名次数最多的被提名者。
CREATE TABLE musical (Nominee VARCHAR)
SELECT Nominee FROM musical GROUP BY Nominee ORDER BY COUNT(*) DESC LIMIT 1
谁是被提名音乐剧最多的的被提名人?
CREATE TABLE musical (RESULT VARCHAR)
SELECT RESULT FROM musical GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1
列出音乐剧最常见的结局。
CREATE TABLE musical (RESULT VARCHAR)
SELECT RESULT FROM musical GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1
返回所有音乐剧中最常见的结局。
CREATE TABLE musical (Nominee VARCHAR)
SELECT Nominee FROM musical GROUP BY Nominee HAVING COUNT(*) > 2
列出被提名超过两部音乐剧的被提名者。
CREATE TABLE musical (Nominee VARCHAR)
SELECT Nominee FROM musical GROUP BY Nominee HAVING COUNT(*) > 2
被提名超过两次的被提名者是谁?
CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR)
SELECT Name FROM musical WHERE NOT Musical_ID IN (SELECT Musical_ID FROM actor)
列出没有演员的音乐剧名称。
CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR), CREATE TABLE actor (Musical_ID VARCHAR, Name VARCHAR)
SELECT Name FROM musical WHERE NOT Musical_ID IN (SELECT Musical_ID FROM actor)
没有演员的音乐剧名称是什么?
CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)
SELECT Nominee FROM musical WHERE Award = "金鸡奖" INTERSECT SELECT Nominee FROM musical WHERE Award = "金马奖"
显示被提名“金鸡奖”和“金马奖”的被提名人。
CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)
SELECT Nominee FROM musical WHERE Award = "金鸡奖" INTERSECT SELECT Nominee FROM musical WHERE Award = "金马奖"
谁被提名过“金鸡奖”和“金马奖”?
CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)
SELECT Nominee FROM musical WHERE Award = "金鸡奖" OR Award = "金像奖"
显示获得“金鸡奖”或“金像奖”奖的被提名音乐人。
CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)
SELECT Nominee FROM musical WHERE Award = "金鸡奖" OR Award = "金像奖"
谁被提名过“金鸡奖”或“金像奖”奖项?
CREATE TABLE user_profiles (email VARCHAR, name VARCHAR)
SELECT email FROM user_profiles WHERE name = '马丽'
找到名为“马丽”的用户的电子邮件。
CREATE TABLE user_profiles (name VARCHAR, partitionid VARCHAR)
SELECT partitionid FROM user_profiles WHERE name = '钢铁侠'
名为“钢铁侠”的用户的ID是什么?
CREATE TABLE user_profiles (Id VARCHAR)
SELECT COUNT(*) FROM user_profiles
有多少用户?
CREATE TABLE follows (Id VARCHAR)
SELECT COUNT(*) FROM follows
每个用户有多少追随者?
CREATE TABLE follows (f1 VARCHAR)
SELECT COUNT(*) FROM follows GROUP BY f1
查找每个用户的追随者数量。
CREATE TABLE tweets (Id VARCHAR)
SELECT COUNT(*) FROM tweets
在记录中找到推文的数量。
CREATE TABLE tweets (UID VARCHAR)
SELECT COUNT(DISTINCT UID) FROM tweets
查找发布了的推文的用户的数量。
CREATE TABLE user_profiles (name VARCHAR, email VARCHAR)
SELECT name, email FROM user_profiles WHERE name LIKE '往事随风'
找出用户名字中含有“往事随风”的人的名字和电子邮箱。
CREATE TABLE user_profiles (name VARCHAR, email VARCHAR)
SELECT name FROM user_profiles WHERE email LIKE '巨星' OR email LIKE 'qq'
找出电子邮箱中中含有“superstar”或是“edu”的用户的名字。
CREATE TABLE tweets (text VARCHAR)
SELECT text FROM tweets WHERE text LIKE '实习'
返回关于“实习”主题的推文。
CREATE TABLE user_profiles (name VARCHAR, email VARCHAR, followers INTEGER)
SELECT name, email FROM user_profiles WHERE followers > 1000
查找拥有超过1000个追随者的用户的姓名和电子邮件。
CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR), CREATE TABLE follows (f1 VARCHAR)
SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING COUNT(*) > (SELECT COUNT(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 WHERE T1.name = '蔡依林')
查找追随者数量大于名为“蔡依林”的用户的用户名称。
CREATE TABLE user_profiles (name VARCHAR, email VARCHAR, uid VARCHAR), CREATE TABLE follows (f1 VARCHAR)
SELECT T1.name, T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING COUNT(*) > 1
查找有不止一个跟随者的用户的姓名和电子邮件。
CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR), CREATE TABLE tweets (uid VARCHAR)
SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) > 1
查找拥有不止一条推特的用户的姓名。
CREATE TABLE user_profiles (uid VARCHAR, name VARCHAR), CREATE TABLE follows (f2 VARCHAR, f1 VARCHAR)
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "马丽" INTERSECT SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "苏晴"
找到被“马丽”和“苏晴”跟随的用户的ID。
CREATE TABLE user_profiles (uid VARCHAR, name VARCHAR), CREATE TABLE follows (f2 VARCHAR, f1 VARCHAR)
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "马丽" OR T1.name = "苏晴"
找到“马丽”或“苏晴”共同追随的用户的ID。
CREATE TABLE user_profiles (name VARCHAR, followers VARCHAR)
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1
查找有最多追随者的用户的名称。
CREATE TABLE user_profiles (name VARCHAR, email VARCHAR, followers VARCHAR)
SELECT name, email FROM user_profiles ORDER BY followers LIMIT 1
找到有最少追随者的用户的名字和电子邮件。
CREATE TABLE user_profiles (name VARCHAR, followers VARCHAR)
SELECT name, followers FROM user_profiles ORDER BY followers DESC
按跟随者数量的降序进行排序,列出每个用户的名称和追随者数目。
CREATE TABLE user_profiles (name VARCHAR, followers VARCHAR)
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 5
列出拥有追随者的最多的前5个用户的名字。
CREATE TABLE tweets (text VARCHAR, createdate VARCHAR)
SELECT text FROM tweets ORDER BY createdate
按日期顺序列出所有推文的文本。
CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR), CREATE TABLE tweets (uid VARCHAR)
SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid
找出每个用户的名字和推特的数量。
CREATE TABLE user_profiles (name VARCHAR, partitionid VARCHAR, uid VARCHAR), CREATE TABLE tweets (uid VARCHAR)
SELECT T1.name, T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) < 2
查找发了不到两次推特的用户的名称和ID。
CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR), CREATE TABLE tweets (uid VARCHAR)
SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) > 1
查找不止一次发推特的用户的姓名,以及他们发推特的次数。
CREATE TABLE user_profiles (UID VARCHAR, followers INTEGER), CREATE TABLE tweets (UID VARCHAR, followers INTEGER)
SELECT AVG(followers) FROM user_profiles WHERE NOT UID IN (SELECT UID FROM tweets)
查找没有任何推特的用户的平均追随者数量。
CREATE TABLE user_profiles (UID VARCHAR, followers INTEGER), CREATE TABLE tweets (UID VARCHAR, followers INTEGER)
SELECT AVG(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
查找有一些推文的用户的平均追随者数量。