Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: How many deli in Belmont have a review rating of 2 or more? deli ris a food type; Belmont refers to city = 'belmont'; review rating of 2 or more refers to review > 2 */
SELECT 
SELECT COUNT(id_restaurant) FROM generalinfo WHERE city = 'belmont' AND review > 2 AND food_type = 'deli'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: Which county in northern California has the highest number of cities? northern California refers to region = 'northern california'; the highest number of cities refers to max(count(city)) */
SELECT 
SELECT county FROM geographic WHERE region = 'northern california' GROUP BY county ORDER BY COUNT(city) DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: How many restaurants can you find in Concord? Concord refers to city = 'concord' */
SELECT 
SELECT COUNT(id_restaurant) FROM location WHERE city = 'concord'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: In which region can you find the top 4 most popular restaurants? the top 4 most popular restaurant refers to top 4 max(review) */
SELECT 
SELECT T2.region FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city ORDER BY T1.review DESC LIMIT 4
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: How many Chinese restaurants are there on 1st st, Livermore? Chinese restaurant refers to food_type = 'chinese'; 1st st refers to street_name = '1st st'; Livermore refers to city = 'livermore' */
SELECT 
SELECT COUNT(T1.id_restaurant) FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'livermore' AND T1.food_type = 'chinese' AND T2.street_name = '1st st'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: How many Indian restaurants are there in the Los Angeles area? Indian restaurant refers to food_type = 'indian'; the Los Angeles area refers to region = 'los angeles area' */
SELECT 
SELECT COUNT(T1.city) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.food_type = 'indian' AND T1.region = 'los angeles area'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: In the Bay Area, what is the most common type of food served by restaurants? the Bay Area refers to region = 'bay area'; the most common type of food refers to max(count(food_type)) */
SELECT 
SELECT T2.food_type FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.region = 'bay area' GROUP BY T2.food_type ORDER BY COUNT(T2.food_type) DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: How many restaurants in Broadway, Oakland received a review of no more than 3? Broadway refers to street_name = 'broadway';  Oakland refers to city = 'oakland'; a review of no more than 3 refers to review < 3 */
SELECT 
SELECT COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.street_name = 'broadway' AND T2.review < 3 AND T1.city = 'oakland'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: In which region can you find the highest number of Baskin Robbins restaurants? the highest number refers to max(count(city)); Baskin Robbins restaurant refers to label = 'baskin robbins' */
SELECT 
SELECT T2.region AS num FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'baskin robbins' GROUP BY T2.region ORDER BY COUNT(T1.city) DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: List all the streets where pizza-serving restaurants are found in San Jose. street refers to street_name; pizza-serving restaurant refers to food_type = 'pizza'; San Jose refers to city = 'san jose' */
SELECT 
SELECT T1.street_name FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.food_type = 'pizza' AND T1.city = 'san jose'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: How many types of restaurants are there in the Yosemite and Mono Lake area? */
SELECT 
SELECT COUNT(T2.food_type) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.region = 'yosemite and mono lake area'
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: What is the full address of the most popular restaurant among the diners? full address refers to street_num, street_name, city; the most popular refers to max(review) */
SELECT 
SELECT T2.street_name, T2.street_num, T2.city FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant ORDER BY T1.review DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: In which counties can you find the restaurant with the highest number of branches? restaurant refers to label; the highest number of branches refers to max(count(city)) */
SELECT 
SELECT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city GROUP BY T2.county ORDER BY COUNT(T1.label) DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: Which region has the highest number of restaurants? the highest number refers to max(count(id_restaurant)) */
SELECT 
SELECT T1.region FROM geographic AS T1 INNER JOIN location AS T2 ON T1.city = T2.city GROUP BY T1.region ORDER BY COUNT(T2.id_restaurant) DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
)

CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
)

CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
)

/* Answer the following: List the full address of all the American restaurants with a review of 4 or more? full address refers to street_num, street_name, city; American restaurant refers to food_type = 'american'; a review of 4 or more refers to review > 4 */
SELECT 
SELECT T1.street_num, T1.street_name, T1.city FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.review >= 4
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What is the release title of the single that was released by Ron Hunt in 1979 that was downloaded 239 times? release title refers to groupName; Ron Hunt is an artist; groupYear = 1979; releaseType = 'single'; downloaded 239 times refer to totalSnatched = 239; */
SELECT 
SELECT groupName FROM torrents WHERE artist LIKE 'ron hunt & ronnie g & the sm crew' AND groupYear = 1979 AND releaseType LIKE 'single' AND totalSnatched = 239
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: How many times was the album released by blowfly in 1980 downloaded? blowfly is an artist; groupYear = 1980; album refers to releaseType; downloaded refers to totalSnatched; */
SELECT 
SELECT totalSnatched FROM torrents WHERE artist LIKE 'blowfly' AND groupYear = 1980
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What is the tag of the album with the highest amount of downloads? album refers to releaseType; the highest amount of downloads refers to MAX(totalSnatched); */
SELECT 
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'album' ORDER BY T1.totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What are the top 5 tags with the highest amount of downloads? the highest amount of downloads refers to MAX(totalSnatched); */
SELECT 
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'album' ORDER BY T1.totalSnatched DESC LIMIT 5
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What is the release title of the single under the "funk" tag that was released the oldest? release title of single refers to groupName where releaseType = 'single'; the oldest means coming before all others in time and refers to MIN(groupYear); */
SELECT 
SELECT T1.groupName FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag LIKE 'funk' AND T1.releaseType = 'single' ORDER BY T1.groupYear LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Name all the release titles of the "ep's" under the alternative tag. release titles of the "ep's" refer to groupName where releaseType = 'ep'; */
SELECT 
SELECT T1.groupName FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag LIKE 'alternative' AND T1.releaseType = 'ep'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What are the tags of the top 5 least downloaded live albums? least downloaded album refers to MIN(totalSnatched where releaseType = 'album'); */
SELECT 
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'album' ORDER BY T1.totalSnatched LIMIT 5
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What is the tag and the artist of the most downloaded single? the most downloaded single refers to MAX(totalSnatched where releaseType = 'single'); */
SELECT 
SELECT T2.tag, T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'single' ORDER BY T1.totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: How many releases are tagged "1980s"? tag = '1980s'; */
SELECT 
SELECT COUNT(id) FROM tags WHERE tag LIKE '1980s'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: How many times has the release "city funk" been downloaded? groupName = 'city funk'; downloaded refers to totalSnatched; */
SELECT 
SELECT totalSnatched FROM torrents WHERE groupName LIKE 'city funk'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Please list the releases that have been downloaded for more than 20000 times. releases refer to groupName; downloaded for more than 20000 times refers to totalSnatched > 20000; */
SELECT 
SELECT groupName FROM torrents WHERE totalSnatched > 20000
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What are the tags of the release "sugarhill gang"? release "sugarhill gang" refers to groupName = 'sugarhill gang'; */
SELECT 
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.groupName = 'sugarhill gang'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: How many tags does the release "city funk" have？ release "city funk" refers to groupName = 'city funk'; */
SELECT 
SELECT COUNT(T2.tag) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.groupName = 'city funk'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Please list the titles of all the releases with the tag "1980s". titles refer to groupName; */
SELECT 
SELECT T1.groupName FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = '1980s'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Among the releases with the tag "1980s", which one of them is the most downloaded? Please give its title. title refers to groupName; the most downloaded refers to MAX(totalSnatched); */
SELECT 
SELECT T1.groupName FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = '1980s' ORDER BY T1.totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: How many releases by the artist michael jackson are tagged "pop"? tag = 'pop'; */
SELECT 
SELECT COUNT(T1.groupName) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'pop' AND T1.artist = 'michael jackson'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Among the releases that were released in 2000, how many of them were released as an album and tagged "pop"? groupYear = 2000; album refers to releaseType; */
SELECT 
SELECT COUNT(T1.groupName) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'pop' AND T1.releaseType = 'album' AND T1.groupYear = 2000
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: What are the average download times for the a release tagged "1980s"? AVG(totalSnatched where tag = '1980s'); */
SELECT 
SELECT CAST(SUM(T1.totalSnatched) AS REAL) / COUNT(T2.tag) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = '1980s'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Name the title of the top three releases with the highest number of downloads. title refers to groupName; the highest number of downloads refers to MAX(totalSnatched); */
SELECT 
SELECT groupName FROM torrents ORDER BY totalSnatched DESC LIMIT 3
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Provide the name of the artist who released his or her Single-Table in 2012 with the highest number of downloads. Name the Single-Table title as well. title refers to groupName; the highest number of downloads refers to MAX(totalSnatched where groupYear = 2012 and releaseType = 'single'); */
SELECT 
SELECT artist, groupName FROM torrents WHERE groupYear = 2012 AND releaseType LIKE 'Single' ORDER BY totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: How many albums and Single-Tables were released by the artist named '50 cent' between 2010 and 2015? albums refer to releaseType = 'album'; releaseType = 'single'; between 2010 and 2015 refers to groupYear between 2010 and 2015; */
SELECT 
SELECT COUNT(id), ( SELECT COUNT(id) FROM torrents WHERE groupYear BETWEEN 2010 AND 2015 AND artist LIKE '50 cent' AND releaseType LIKE 'album' ) FROM torrents WHERE groupYear BETWEEN 2010 AND 2015 AND artist LIKE '50 cent' AND releaseType LIKE 'Single'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: An American rapper '2Pac' released his first solo album in 1991, how many years have passed until his next album was released? 2Pac is an artist; album refers to releaseType; groupYear = 1991; SUBTRACT(groupYear = 1991, groupYear where releaseType = 'album' LIMIT 1 OFFSET 1); */
SELECT 
SELECT ( SELECT groupYear FROM torrents WHERE artist LIKE '2Pac' AND releaseType LIKE 'album' ORDER BY groupYear LIMIT 1, 1 ) - groupYear FROM torrents WHERE artist LIKE '2Pac' AND releaseType LIKE 'album' AND groupYear = 1991
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Find the average number of downloads for Single-Tables released by '2Pac' between 2001 and 2013. 2Pac is an artist; releaseType = 'single'; between 2001 and 2013 refers to groupYear between 2001 and 2013; average number of downloads = AVG(totalSnatched); */
SELECT 
SELECT AVG(totalSnatched) FROM torrents WHERE artist LIKE '2Pac' AND releaseType LIKE 'Single' AND groupYear BETWEEN 2001 AND 2013
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Provide the title, release year and the tag associated with the live album that has the highest number of downloads? release year refers to groupYear; title of live album refers to groupName where releaseType = 'live album'; the highest number of downloads refers to MAX(totalSnatched); */
SELECT 
SELECT T1.groupName, T1.groupYear, T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'live album' ORDER BY T1.totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Provide the name of artists who released at least two bootlegs in 2016. at least two bootlegs refer to COUNT(releaseType = 'bootleg')≥ 2; groupYear = 2016; */
SELECT 
SELECT artist FROM torrents WHERE groupYear = 2016 AND releaseType LIKE 'bootleg' GROUP BY artist HAVING COUNT(releaseType) > 2
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Which artist released singles between 1980 to 1982? releaseType = 'single'; between 1980 to 1982 refers to groupYear between 1980 and 1982; */
SELECT 
SELECT artist FROM torrents WHERE groupYear BETWEEN 1980 AND 1982 AND releaseType LIKE 'single'
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Indicates groups with id from 10 to 20 with singles downloaded at least 20. releaseType = 'single'; downloaded at least 20 refers to totalSnatched ≥ 20; id from 10 to 20 refer to id between 10 and 20; groups refer to groupName; */
SELECT 
SELECT groupName FROM torrents WHERE totalSnatched >= 20 AND releaseType LIKE 'single' AND id BETWEEN 10 AND 20
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Among the artists from 1980 to 1982. Which artist was tagged as "disco"? from 1980 to 1982 refers to groupYear between 1980 and 1982; tag = 'disco'; */
SELECT 
SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'disco' AND T1.groupYear BETWEEN 1980 AND 1982
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Provide the name of artists who had no more than 100 downloads and are tagged "funk" in 1980. no more than 100 downloads refer to totalSnatched ≤ 100; groupYear = 1980; tag = 'funk'; */
SELECT 
SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'funk' AND T1.groupYear = 1980 AND T1.totalSnatched <= 100
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Which artist has released the most singles with the tag "soul"? the most singles refer to MAX(COUNT(releaseType = 'single')); */
SELECT 
SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'soul' AND T1.releaseType = 'single' GROUP BY T1.artist ORDER BY COUNT(T1.releaseType) DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Among the artists with the id from 10 to 30. Which artist released the product with the tag "funk" in 1980? id from 10 to 30 refers to id between 10 and 30; groupYear = 1980; */
SELECT 
SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'funk' AND T1.groupYear = 1980 AND T1.id BETWEEN 10 AND 30
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: List the group name has the most downloaded that have released jazz genres from 1982 or later. the most downloaded refers to MAX(totalSnatched); tag = 'jazz'; from 1982 or later refers to groupYear ≥ 1982; */
SELECT 
SELECT T1.groupName FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'jazz' AND T1.groupYear >= 1982 ORDER BY T1.totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Which artist has id "16"? Provide her or his tag genre. FALSE; */
SELECT 
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.id = 16
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: Among id from 10 to 50. Which artist tagged as "new.york" has the most downloads? Among id from 10 to 50 refers to id between 10 and 50; tag = 'new.york'; the most downloads refer to MAX(totalSnatched); */
SELECT 
SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.id BETWEEN 10 AND 50 AND T2.tag LIKE 'new.york' ORDER BY T1.totalSnatched DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
)

CREATE TABLE "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
)

/* Answer the following: List the name of artists who have released albums and mixtape from 1980 to 1985 in "dance" genre. albums and mixtape refer to releaseType; from 1980 to 1985 refers to groupYear between 1980 and 1985; tag = 'dance'; */
SELECT 
SELECT COUNT(T1.artist) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'dance' AND T1.groupYear BETWEEN 1980 AND 1985 AND T1.releaseType LIKE 'album' OR T1.releaseType LIKE 'mixtape'