db_id stringclasses 146 values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146 values |
|---|---|---|---|
epinions_1 | Find the titles of items whose rating is higher than the average review rating of all items. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > (SELECT avg(rating) FROM review) | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the titles of items that received any rating below 5. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the titles of items that received both a rating higher than 8 and a rating below 5. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > 8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the names of items whose rank is higher than 3 and whose average rating is above 5. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rank > 3 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id HAVING avg(T2.rating) > 5 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name of the item with the lowest average rating. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | List the titles of all items in alphabetic order . | SELECT title FROM item ORDER BY title | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name of the user who gives the most reviews. | SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name and id of the item with the highest average rating. | SELECT T1.title , T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) DESC LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name and id of the good with the highest average rank. | SELECT T1.title , T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rank) DESC LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | For each user, return the name and the average rating of reviews given by them. | SELECT T1.name , avg(T2.rating) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | For each user, find their name and the number of reviews written by them. | SELECT T1.name , count(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name of the user who gave the highest rating. | SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id ORDER BY T2.rating DESC LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name of the source user with the highest average trust score. | SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.source_u_id GROUP BY T2.source_u_id ORDER BY avg(trust) DESC LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find each target user's name and average trust score. | SELECT T1.name , avg(trust) FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id GROUP BY T2.target_u_id | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the name of the target user with the lowest trust score. | SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id ORDER BY trust LIMIT 1 | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the names of the items that did not receive any review. | SELECT title FROM item WHERE i_id NOT IN (SELECT i_id FROM review) | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the names of users who did not leave any review. | SELECT name FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review) | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the number of users who did not write any review. | SELECT count(*) FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review) | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
epinions_1 | Find the number of items without any review. | SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review) | CREATE TABLE `item` (
`i_id` integer NOT NULL
, `title` varchar(20) DEFAULT NULL
, PRIMARY KEY (`i_id`)
)
3 rows from item table:
i_id title
0 pear
1 orange
2 apple
CREATE TABLE `review` (
`a_id` integer NOT NULL PRIMARY KEY
, `u_id` integer NOT NULL
, `i_id` integer NOT NULL
, `rating` integer DEFAULT NULL
, `rank` integer DEFAULT NULL
, FOREIGN KEY (`u_id`) REFERENCES `useracct`(`u_id`)
, FOREIGN KEY (`i_id`) REFERENCES `item`(`i_id`)
)
3 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
3 1 4 7 3
CREATE TABLE `useracct` (
`u_id` integer NOT NULL
, `name` varchar(128) DEFAULT NULL
, PRIMARY KEY (`u_id`)
)
3 rows from useracct table:
u_id name
1 Helen
2 Mark
3 Terry
CREATE TABLE "trust" (`source_u_id` integer NOT NULL, `target_u_id` integer NOT NULL, `trust` integer NOT NULL, FOREIGN KEY (`source_u_id`) REFERENCES `useracct`(`u_id`), FOREIGN KEY (`target_u_id`) REFERENCES `useracct`(`u_id`))
3 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
2 4 8
|
riding_club | How many players are there? | SELECT count(*) FROM player | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | List the names of players in ascending order of votes. | SELECT Player_name FROM player ORDER BY Votes ASC | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | What are the gender and occupation of players? | SELECT Gender , Occupation FROM player | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | List the name and residence for players whose occupation is not "Researcher". | SELECT Player_name , residence FROM player WHERE Occupation != "Researcher" | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the names of sponsors of players whose residence is either "Brandon" or "Birtle". | SELECT Sponsor_name FROM player WHERE Residence = "Brandon" OR Residence = "Birtle" | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | What is the name of the player with the largest number of votes? | SELECT Player_name FROM player ORDER BY Votes DESC LIMIT 1 | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show different occupations along with the number of players in each occupation. | SELECT Occupation , COUNT(*) FROM player GROUP BY Occupation | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Please show the most common occupation of players. | SELECT Occupation FROM player GROUP BY Occupation ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the residences that have at least two players. | SELECT Residence FROM player GROUP BY Residence HAVING COUNT(*) >= 2 | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the names of players and names of their coaches. | SELECT T3.Player_name , T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the names of players coached by the rank 1 coach. | SELECT T3.Player_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T2.Rank = 1 | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the names and genders of players with a coach starting after 2011. | SELECT T3.Player_name , T3.gender FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T1.Starting_year > 2011 | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the names of players and names of their coaches in descending order of the votes of players. | SELECT T3.Player_name , T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID ORDER BY T3.Votes DESC | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | List the names of players that do not have coaches. | SELECT Player_name FROM player WHERE Player_ID NOT IN (SELECT Player_ID FROM player_coach) | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | Show the residences that have both a player of gender "M" and a player of gender "F". | SELECT Residence FROM player WHERE gender = "M" INTERSECT SELECT Residence FROM player WHERE gender = "F" | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | How many coaches does each club has? List the club id, name and the number of coaches. | SELECT T1.club_id , T1.club_name, count(*) FROM club AS T1 JOIN coach AS T2 ON T1.club_id = T2.club_id GROUP BY T1.club_id | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
riding_club | How many gold medals has the club with the most coaches won? | SELECT T1.club_id , T1.gold FROM match_result AS T1 JOIN coach AS T2 ON T1.club_id = T2.club_id GROUP BY T1.club_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)
3 rows from player table:
Player_ID Sponsor_name Player_name Gender Residence Occupation Votes Rank
1 Brandon—Souris Jean Luc Bouché M Brandon Locomotive Engineer 6055 2nd
2 Charleswood—St. James—Assiniboia Fiona Shiells F Winnipeg Ministerial Assistant 7190 3rd
3 Churchill Niki Ashton F Thompson Researcher 8734 1st
CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)
3 rows from club table:
Club_ID Club_name Region Start_year
1 AIK USA 2009
2 BK Häcken UK 1998
3 Djurgårdens IF USA 2005
CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from coach table:
Coach_ID Coach_name Gender Club_ID Rank
1 Jameson Tomas M 1 1
2 Joe Fabbri F 1 2
3 Robert Chen M 3 3
CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)
3 rows from player_coach table:
Player_ID Coach_ID Starting_year
1 1 2010
2 1 2011
3 1 2012
CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)
3 rows from match_result table:
Rank Club_ID Gold Big_Silver Small_Silver Bronze Points
1 1 20 14 9 8 168
2 2 13 11 16 9 139
3 3 12 9 4 7 102
|
gymnast | How many gymnasts are there? | SELECT count(*) FROM gymnast | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Count the number of gymnasts. | SELECT count(*) FROM gymnast | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | List the total points of gymnasts in descending order. | SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the total points for all gymnasts, ordered by total points descending? | SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | List the total points of gymnasts in descending order of floor exercise points. | SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the total points of gymnasts, ordered by their floor exercise points descending? | SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What is the average horizontal bar points for all gymnasts? | SELECT avg(Horizontal_Bar_Points) FROM gymnast | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the average horizontal bar points across all gymnasts. | SELECT avg(Horizontal_Bar_Points) FROM gymnast | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the names of people in ascending alphabetical order? | SELECT Name FROM People ORDER BY Name ASC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the names of people, ordered alphabetically. | SELECT Name FROM People ORDER BY Name ASC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the names of gymnasts? | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the names of the gymnasts. | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the names of gymnasts whose hometown is not "Santo Domingo"? | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T2.Hometown != "Santo Domingo" | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the names of gymnasts who did not grow up in Santo Domingo. | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T2.Hometown != "Santo Domingo" | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What is the age of the tallest person? | SELECT Age FROM people ORDER BY Height DESC LIMIT 1 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the age of the person with the greatest height. | SELECT Age FROM people ORDER BY Height DESC LIMIT 1 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | List the names of the top 5 oldest people. | SELECT Name FROM People ORDER BY Age DESC LIMIT 5 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the names of the five oldest people? | SELECT Name FROM People ORDER BY Age DESC LIMIT 5 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What is the total point count of the youngest gymnast? | SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Age ASC LIMIT 1 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the total points of the gymnast with the lowest age. | SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Age ASC LIMIT 1 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What is the average age of all gymnasts? | SELECT avg(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the average age across all gymnasts. | SELECT avg(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the distinct hometowns of gymnasts with total points more than 57.5? | SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T1.Total_Points > 57.5 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Give the different hometowns of gymnasts that have a total point score of above 57.5. | SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T1.Total_Points > 57.5 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the hometowns of gymnasts and the corresponding number of gymnasts? | SELECT T2.Hometown , COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | How many gymnasts are from each hometown? | SELECT T2.Hometown , COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What is the most common hometown of gymnasts? | SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Return the hometown that is most common among gymnasts. | SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the hometowns that are shared by at least two gymnasts? | SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown HAVING COUNT(*) >= 2 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Give the hometowns from which two or more gymnasts are from. | SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown HAVING COUNT(*) >= 2 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | List the names of gymnasts in ascending order by their heights. | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Height ASC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the names of gymnasts, ordered by their heights ascending? | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Height ASC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | List the distinct hometowns that are not associated with any gymnast. | SELECT DISTINCT Hometown FROM people EXCEPT SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | From which hometowns did no gymnasts come from? | SELECT DISTINCT Hometown FROM people EXCEPT SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Show the hometowns shared by people older than 23 and younger than 20. | SELECT Hometown FROM people WHERE Age > 23 INTERSECT SELECT Hometown FROM people WHERE Age < 20 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | From which hometowns did both people older than 23 and younger than 20 come from? | SELECT Hometown FROM people WHERE Age > 23 INTERSECT SELECT Hometown FROM people WHERE Age < 20 | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | How many distinct hometowns did these people have? | SELECT count(DISTINCT Hometown) FROM people | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Count the number of different hometowns of these people. | SELECT count(DISTINCT Hometown) FROM people | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | Show the ages of gymnasts in descending order of total points. | SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T1.Total_Points DESC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
gymnast | What are the ages of the gymnasts, ordered descending by their total points? | SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T1.Total_Points DESC | CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)
3 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.750 58.061
2 9.700 9.625 9.625 9.650 9.587 9.737 57.924
4 8.987 9.750 9.750 9.650 9.787 9.725 57.649
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)
3 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
3 Ashley Pérez Cabrera 19.0 1.70 Miami
|
small_bank_1 | Find the total savings balance of all accounts except the account with name ‘Brown’. | SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T1.name != 'Brown' | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What is the total balance of savings accounts not belonging to someone with the name Brown? | SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T1.name != 'Brown' | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | How many accounts are there in total? | SELECT count(*) FROM accounts | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Count the number of accounts. | SELECT count(*) FROM accounts | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What is the total checking balance in all accounts? | SELECT sum(balance) FROM checking | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the total balance across checking accounts. | SELECT sum(balance) FROM checking | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the average checking balance. | SELECT avg(balance) FROM checking | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What is the average balance in checking accounts? | SELECT avg(balance) FROM checking | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | How many accounts have a savings balance above the average savings balance? | SELECT count(*) FROM savings WHERE balance > (SELECT avg(balance) FROM savings) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the number of accounts with a savings balance that is higher than the average savings balance. | SELECT count(*) FROM savings WHERE balance > (SELECT avg(balance) FROM savings) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the name and id of accounts whose checking balance is below the maximum checking balance. | SELECT T1.custid , T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT max(balance) FROM checking) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What are the customer id and name corresponding to accounts with a checking balance less than the largest checking balance? | SELECT T1.custid , T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT max(balance) FROM checking) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What is the checking balance of the account whose owner’s name contains the substring ‘ee’? | SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%' | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the balance of the checking account belonging to an owner whose name contains 'ee'. | SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%' | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the checking balance and saving balance in the Brown’s account. | SELECT T2.balance , T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T1.name = 'Brown' | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What are the checking and savings balances in accounts belonging to Brown? | SELECT T2.balance , T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T1.name = 'Brown' | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance. | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT avg(balance) FROM savings) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What are the names of accounts with checking balances greater than the average checking balance and savings balances below the average savings balance? | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT avg(balance) FROM savings) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the checking balance of the accounts whose savings balance is higher than the average savings balance. | SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM savings)) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What are the balances of checking accounts belonging to people with savings balances greater than the average savings balance? | SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM savings)) | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | List all customers’ names in the alphabetical order. | SELECT name FROM accounts ORDER BY name | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What are the names of all the customers in alphabetical order? | SELECT name FROM accounts ORDER BY name | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | Find the name of account that has the lowest total checking and saving balance. | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T2.balance + T3.balance LIMIT 1 | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
small_bank_1 | What is the name corresponding to the accoung with the lowest sum of checking and savings balances? | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T2.balance + T3.balance LIMIT 1 | CREATE TABLE ACCOUNTS (
custid BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL
)
3 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
3 O'mahony
CREATE TABLE SAVINGS (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
3 230000.0
CREATE TABLE CHECKING (
custid BIGINT NOT NULL PRIMARY KEY,
balance FLOAT NOT NULL,
FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)
3 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
3 3000.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.