input
stringlengths 193
2.69k
| output
stringlengths 24
744
|
|---|---|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
Please write me a SQL statement that answers the following question: How many cars on train no.1 have the roof open? [/INST]
|
SELECT COUNT(id) FROM cars WHERE train_id = 1 AND roof = 'none';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
Please write me a SQL statement that answers the following question: Please list the IDs of all the cars on train no.1 that have 2 wheels. [/INST]
|
SELECT id FROM cars WHERE train_id = 1 AND wheels = 2;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the trains that run in the east direction, how many of them have at least one car in a non-regular shape? [/INST]
|
SELECT SUM(CASE WHEN T1.shape IN ('bucket', 'elipse') THEN 1 ELSE 0 end)as count FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the IDs of all the trains that run in the east direction and have less than 4 cars. [/INST]
|
SELECT T1.id FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS carsNum FROM cars GROUP BY train_id ) AS T2 ON T1.id = T2.train_id WHERE T1.direction = 'east' AND T2.carsNum < 4;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the IDs of all the cars with double sides on trains that run in the west direction. [/INST]
|
SELECT T1.id FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east' AND T1.sides = 'double';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the trains that run in the east direction, how many of them have more than 2 long cars? [/INST]
|
SELECT SUM(CASE WHEN T2.longCarsNum > 2 THEN 1 ELSE 0 END)as count FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) AS longCarsNum FROM cars WHERE len = 'long' GROUP BY train_id ) AS T2 ON T1.id = T2.train_id WHERE T1.direction = 'west';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the directions in which the trains with at least one empty-loaded car run. [/INST]
|
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.load_num = 0;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: In which direction does the train with an ellipse-shape car run? [/INST]
|
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.shape = 'ellipse';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: What is the total number of short cars on all the trains that run in the east direction? [/INST]
|
SELECT SUM(CASE WHEN T1.len = 'short' then 1 ELSE 0 END)as count FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the shapes of all the head cars on the trains that run in the east direction. [/INST]
|
SELECT T1.shape FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east' AND T1.position = 1 GROUP BY T1.shape;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: How many cars on a train that runs in the east direction have a flat roof? [/INST]
|
SELECT SUM(CASE WHEN T1.roof = 'flat' THEN 1 ELSE 0 END)as count FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the cars on a train that runs in the east direction, how many of them have a flat roof and a circle load shape? [/INST]
|
SELECT SUM(CASE WHEN T1.load_shape = 'circle' THEN 1 ELSE 0 END)as count FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east' AND T1.roof = 'flat' ;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Trains that run in which direction have more rectangle-shaped cars in total? [/INST]
|
SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) AS rectCarsNum FROM cars WHERE shape = 'rectangle' GROUP BY train_id ) AS T2 ON T1.id = T2.train_id ORDER BY T2.rectCarsNum DESC;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the directions in which the trains with 4 short cars run. [/INST]
|
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.len = 'short' AND T1.position = 4;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average number of cars on trains that run in the east direction? [/INST]
|
SELECT CAST(COUNT(T1.id) AS REAL) / COUNT(DISTINCT T1.train_id) FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T2.direction = 'east';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the trains that have at least one non-regular shaped car, what is the percentage of it running in the east direction? [/INST]
|
SELECT CAST(COUNT(DISTINCT CASE WHEN T2.direction = 'east' THEN T1.train_id ELSE NULL END) AS REAL) * 100 / COUNT(DISTINCT T1.train_id) FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.shape IN ('bucket', 'ellipse');
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
Please write me a SQL statement that answers the following question: How many short cars are in the shape of hexagon? [/INST]
|
SELECT COUNT(id) FROM cars WHERE shape = 'hexagon' AND len = 'short';
|
[INST] Here is a database schema:
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: How many trains are running west? [/INST]
|
SELECT COUNT(id) FROM trains WHERE direction = 'west';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
Please write me a SQL statement that answers the following question: What are the load shapes of all the short ellipse cars? [/INST]
|
SELECT load_shape FROM cars WHERE shape = 'ellipse' AND len = 'short';
|
[INST] Here is a database schema:
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: What are the ids of the train running east? [/INST]
|
SELECT id FROM trains WHERE direction = 'east';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
Please write me a SQL statement that answers the following question: How many wheels do the long cars have? [/INST]
|
SELECT SUM(wheels) FROM cars WHERE len = 'long';
|
[INST] Here is a database schema:
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Which direction do the majority of the trains are running? [/INST]
|
SELECT direction FROM trains GROUP BY direction ORDER BY COUNT(id) DESC;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the trains running east, how many trains have at least 4 cars? [/INST]
|
SELECT SUM(CASE WHEN T1.direction = 'east' THEN 1 ELSE 0 END)as count FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) AS carsNum FROM cars GROUP BY train_id ) AS T2 ON T1.id = T2.train_id WHERE T2.carsNum >= 4;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Which direction do most of the trains with rectangle-shaped second cars run? [/INST]
|
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 2 AND T1.shape = 'rectangle' GROUP BY T2.direction ORDER BY COUNT(T2.id) DESC LIMIT 1;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: How many trains running west have double sided cars in 3rd position? [/INST]
|
SELECT COUNT(T.train_id) FROM (SELECT T1.train_id FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 3 AND T2.direction = 'west' AND T1.sides = 'double' GROUP BY T1.train_id)as T;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: How many eastbound trains have rectangular-shaped head cars? [/INST]
|
SELECT COUNT(T.train_id) FROM (SELECT T1.train_id FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 1 AND T2.direction = 'east' AND T1.shape = 'rectangle' GROUP BY T1.train_id)as T;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the trains running west, how many trains have no more than one car with an open roof? [/INST]
|
SELECT SUM(CASE WHEN T1.direction = 'west' THEN 1 ELSE 0 END)as count FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) FROM cars WHERE roof = 'none' GROUP BY train_id HAVING COUNT(id) = 1 ) AS T2 ON T1.id = T2.train_id ;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Which direction does the majority of the trains that have 3 cars are running? [/INST]
|
SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) AS carsNum FROM cars GROUP BY train_id HAVING carsNum = 3 ) AS T2 ON T1.id = T2.train_id GROUP BY T1.direction;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: How many trains with fully loaded head cars are running east? [/INST]
|
SELECT COUNT(DISTINCT T1.train_id) FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 1 AND T1.load_num = 3;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: How many cars running east have double-sided tail cars? [/INST]
|
SELECT COUNT(T1.id) FROM trains AS T1 INNER JOIN cars AS T2 ON T1.id = T2.train_id INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars GROUP BY train_id ) AS T3 ON T1.id = T3.train_id WHERE T1.direction = 'east' AND T2.position = T3.trailPosi AND T2.sides = 'double';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: List all the directions of the trains that have empty cars. [/INST]
|
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.load_num = 0;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: What is the direction of the train with a diamond-shaped load in its 2nd car? [/INST]
|
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 2 AND T1.shape = 'diamond';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Among the trains running west, how many trains have three-wheeled, jagged roof cars? [/INST]
|
SELECT SUM(CASE WHEN T2.direction = 'west' THEN 1 ELSE 0 END)as count FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.wheels = 3 AND T1.roof = 'jagged';
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: Provide the directions for all the trains that have 2 or less cars. [/INST]
|
SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars GROUP BY train_id ) AS T2 ON T1.id = T2.train_id WHERE T2.trailPosi <= 2;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: What is the percentage of all the trains with at least 4 cars? List the directions of the said trains. [/INST]
|
SELECT CAST(COUNT(CASE WHEN T2.trailPosi >= 4 THEN T1.id ELSE NULL END) AS REAL) * 100 / COUNT(T1.id) FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars GROUP BY train_id ) AS T2 ON T1.id = T2.train_id UNION ALL SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars t GROUP BY train_id ) AS T2 ON T1.id = T2.train_id AND T2.trailPosi >= 4;
|
[INST] Here is a database schema:
cars :
id [ INTEGER ] primary_key
train_id [ INTEGER ] cars.train_id = trains.id
position [ INTEGER ]
shape [ TEXT ]
len [ TEXT ]
sides [ TEXT ]
roof [ TEXT ]
wheels [ INTEGER ]
load_shape [ TEXT ]
load_num [ INTEGER ]
trains :
id [ INTEGER ] primary_key
direction [ TEXT ]
Please write me a SQL statement that answers the following question: List all the load shapes of all head cars of each train and identify which load shape has the highest number. Calculate the percentage of the trains with the said head car that are running eas [/INST]
|
SELECT DISTINCT T3.load_shape FROM ( SELECT load_shape, train_id FROM cars WHERE position = 1 ORDER BY train_id DESC ) AS T3 UNION ALL SELECT T4.load_shape FROM ( SELECT load_shape, train_id FROM cars WHERE position = 1 ORDER BY train_id DESC LIMIT 1 ) AS T4 UNION ALL SELECT (CAST(COUNT(DISTINCT CASE WHEN T2.direction = 'east' THEN T2.id ELSE NULL END) AS REAL) * 100 / COUNT(DISTINCT T2.id)) FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 1 AND T1.load_shape = ( SELECT T4.load_shape FROM ( SELECT load_shape, train_id FROM cars AS T WHERE position = 1 ORDER BY train_id DESC LIMIT 1 ) AS T4 );
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the names of the actors who played a role in the movie Batman. [/INST]
|
SELECT T3.Name FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Title = 'Batman';
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the names of the movies starring Tom Cruise. [/INST]
|
SELECT T1.Title FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T3.Name = 'Tom Cruise';
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: Among the movies starring Tom Cruise, which one of them has the best quality? [/INST]
|
SELECT T1.Title FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T3.Name = 'Tom Cruise' ORDER BY T1.Rating DESC LIMIT 1;
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: How many movies star a male African American actor? [/INST]
|
SELECT COUNT(*) FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID WHERE T2.Gender = 'Male' AND T2.Ethnicity = 'African American';
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average rating of all the movies starring Tom Cruise? [/INST]
|
SELECT AVG(T1.Rating) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T3.Name = 'Tom Cruise';
|
[INST] Here is a database schema:
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: How much longer in percentage is the screen time of the most important character in Batman than the least important one? [/INST]
|
SELECT (MAX(CAST(SUBSTR(T2.screentime, 3, 2) AS REAL)) - MIN(CAST(SUBSTR(T2.screentime, 3, 2) AS REAL))) * 100 / MIN(CAST(SUBSTR(T2.screentime, 3, 2) AS REAL)) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID WHERE T1.Title = 'Batman';
|
[INST] Here is a database schema:
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
Please write me a SQL statement that answers the following question: Which movie had the biggest budget? Give the name of the movie. [/INST]
|
SELECT Title FROM movie ORDER BY Budget DESC LIMIT 1;
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: Who was the actor that played in the movie "Batman" with the longest screentime? [/INST]
|
SELECT T2.Name FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID INNER JOIN movie AS T3 ON T3.MovieID = T1.MovieID WHERE T3.Title = 'Batman' ORDER BY T1.screentime DESC LIMIT 1;
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: How many movies has the highest networth actor acted in? [/INST]
|
SELECT COUNT(*) FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID WHERE CAST(REPLACE(REPLACE(T2.NetWorth, ',', ''), '$', '') AS REAL) = ( SELECT MAX(CAST(REPLACE(REPLACE(NetWorth, ',', ''), '$', '') AS REAL)) FROM actor);
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: Who played the No.2 character in the credit list of the movie "American Hustle"? [/INST]
|
SELECT T3.Name FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Title = 'American Hustle' AND T2.creditOrder = '2';
|
[INST] Here is a database schema:
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
Please write me a SQL statement that answers the following question: List down the movie ID of movie with a budget of 15000000 and a rating between 7 to 8. [/INST]
|
SELECT MovieID FROM movie WHERE Rating BETWEEN 7 AND 8 AND Budget = 15000000;
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
Please write me a SQL statement that answers the following question: What is the name of male and white actor with actor ID 439? [/INST]
|
SELECT Name FROM actor WHERE ActorID = 439 AND Gender = 'Male' AND Ethnicity = 'White';
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: In romantic movies, how many of them starred by John Travolta? [/INST]
|
SELECT COUNT(*) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Genre = 'Romance' AND T3.Name = 'John Travolta';
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: What is the gross of a comedy movie with a rating lower than 7 and starred by an actor with a net worth greater than $375,000,000.00? [/INST]
|
SELECT SUM(T1.Gross) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE CAST(REPLACE(REPLACE(T3.NetWorth, ',', ''), '$', '') AS REAL) > 375000000 AND T1.Rating < 7 AND T1.Genre = 'Comedy';
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: What is the runtime of the movie starred by Jackie Chan with a rating greater than 7? [/INST]
|
SELECT T1.Runtime FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T3.Name = 'Jackie Chan' AND T1.Rating > 7;
|
[INST] Here is a database schema:
actor :
ActorID [ INTEGER ] primary_key
Name [ TEXT ]
Date of Birth [ DATE ]
Birth City [ TEXT ]
Birth Country [ TEXT ]
Height (Inches) [ INTEGER ]
Biography [ TEXT ]
Gender [ TEXT ]
Ethnicity [ TEXT ]
NetWorth [ TEXT ]
movie :
MovieID [ INTEGER ] primary_key
Title [ TEXT ]
MPAA Rating [ TEXT ]
Budget [ INTEGER ]
Gross [ INTEGER ]
Release Date [ TEXT ]
Genre [ TEXT ]
Runtime [ INTEGER ]
Rating [ REAL ]
Rating Count [ INTEGER ]
Summary [ TEXT ]
characters :
MovieID [ INTEGER ] characters.MovieID = movie.MovieID
ActorID [ INTEGER ] characters.ActorID = actor.ActorID
Character Name [ TEXT ]
creditOrder [ INTEGER ]
pay [ TEXT ]
screentime [ TEXT ]
Please write me a SQL statement that answers the following question: Among the movies with drama genre, what is the percentage of the actors with net worth greater than $400,000,000.00? [/INST]
|
SELECT SUM(CASE WHEN CAST(REPLACE(REPLACE(T3.NetWorth, ',', ''), '$', '') AS REAL) > 400000000 THEN 1 ELSE 0 END) - SUM(CASE WHEN CAST(REPLACE(REPLACE(T3.NetWorth, ',', ''), '$', '') AS REAL) < 400000000 THEN 1 ELSE 0 END) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Genre = 'Drama';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many tweets are in English? [/INST]
|
SELECT COUNT(TweetID) AS tweet_number FROM twitter WHERE Lang = 'en';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Please list the texts of all the tweets that are reshared. [/INST]
|
SELECT text FROM twitter WHERE IsReshare = 'TRUE';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many tweets are seen by more than 1000 unique users? [/INST]
|
SELECT COUNT(TweetID) AS tweet_number FROM twitter WHERE Reach > 1000;
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Among all the tweets that have a positive sentiment, how many of them are posted on Thursday? [/INST]
|
SELECT COUNT(TweetID) AS tweet_number FROM twitter WHERE Sentiment > 0 AND Weekday = 'Thursday';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the text of the tweet that got the most `likes`? [/INST]
|
SELECT text FROM twitter WHERE Likes = ( SELECT MAX( Likes) FROM twitter );
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
Please write me a SQL statement that answers the following question: Please list all the cities in Argentina. [/INST]
|
SELECT City FROM location WHERE City IS NOT NULL AND Country = 'Argentina';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many tweets in total were posted by a user in Argentina? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.Country = 'Argentina' LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Users in which city of Argentina post the most tweets? [/INST]
|
SELECT T2.City FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.Country = 'Argentina' GROUP BY T2.City ORDER BY COUNT(T1.TweetID) DESC LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Among all the tweets that are reshared, how many of them are posted by a user in Buenos Aires? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.City = 'Buenos Aires' AND T1.IsReshare = 'TRUE';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Please list the texts of all the tweets posted from Buenos Aires with a positive sentiment. [/INST]
|
SELECT T1.text FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Sentiment > 0 AND T2.City = 'Buenos Aires';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: From which country is the tweet with the most likes posted? [/INST]
|
SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID ORDER BY T1.Likes DESC LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Users in which country has posted more numbers of positive tweets, Argentina or Australia? [/INST]
|
SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.Country IN ('Argentina', 'Australia') AND T1.Sentiment > 0 GROUP BY T2.Country ORDER BY COUNT(T1.TweetID) DESC LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Among all the tweets posted from Buenos Aires, how many of them were posted on Thursdays? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.City = 'Buenos Aires' AND T1.Weekday = 'Thursday';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Among all the users that have posted a tweet with over 1000 likes, how many of them are male? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.Likes > 10 AND T2.Gender = 'Male';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many tweets have the male users posted in total? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Male';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the gender of the user who has posted the tweet that is seen by the most number of unique users? [/INST]
|
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID ORDER BY T1.Reach DESC LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many tweets are posted by male users in Argentina? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T3 ON T1.UserID = T3.UserID WHERE T3.Gender = 'Male' AND T2.Country = 'Argentina';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Please list the texts of all the tweets posted by male users from Buenos Aires. [/INST]
|
SELECT T1.text FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T2 ON T2.UserID = T1.UserID INNER JOIN user AS T3 ON T1.UserID = T3.UserID WHERE T2.City = 'Buenos Aires' AND T3.Gender = 'Male';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the average number of tweets posted by the users in a city in Argentina? [/INST]
|
SELECT SUM(CASE WHEN T2.City = 'Buenos Aires' THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS avg FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.Country = 'Argentina';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Among all the tweets with a positive sentiment, what is the percentage of those posted by a male user? [/INST]
|
SELECT SUM(CASE WHEN T2.Gender = 'Male' THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS per FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.Sentiment > 0;
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
Please write me a SQL statement that answers the following question: Give the number of users who do not show their genders. [/INST]
|
SELECT COUNT(UserID) AS user_number FROM user WHERE Gender = 'Unknown';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
Please write me a SQL statement that answers the following question: State the number of states in the United Kingdom. [/INST]
|
SELECT COUNT(State) AS State_number FROM location WHERE Country = 'United Kingdom';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
Please write me a SQL statement that answers the following question: What is the code of Gwynedd State? [/INST]
|
SELECT DISTINCT StateCode FROM location WHERE State = 'Gwynedd';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
Please write me a SQL statement that answers the following question: Give the location id of West Sussex State. [/INST]
|
SELECT DISTINCT LocationID FROM location WHERE State = 'West Sussex';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many reshared tweets are there in Texas? [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.State = 'Texas' AND T1.IsReshare = 'TRUE';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: For the tweet which got a reach number of 547851, which country did it come from? [/INST]
|
SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Reach = 547851;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: State the number of positive tweets from Ha Noi. [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Sentiment > 0 AND T2.State = 'Ha Noi';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Show the text of the tweet with the highest klout from Connecticut. [/INST]
|
SELECT T1.text FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.State = 'Connecticut' ORDER BY T1.Klout DESC LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many female Twitter users are there from Wisconsin? [/INST]
|
SELECT COUNT(T1.Likes) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T3 ON T3.UserID = T1.UserID WHERE T2.State = 'Wisconsin' AND T3.Gender = 'Female';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the gender of the user who tweeted `tw-715909161071091712`? [/INST]
|
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.TweetID = 'tw-715909161071091712';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Give the name of the city of the user who tweeted `One of our favorite stories is @FINRA_News's move to the cloud with AWS Enterprise Support! https://amp.twimg.com/v/991837f1-4815-4edc-a88f-e68ded09a02a`. [/INST]
|
SELECT T2.City FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.text = 'One of our favorite stories is @FINRA_News''s move to the cloud with AWS Enterprise Support! https://amp.twimg.com/v/991837f1-4815-4edc-a88f-e68ded09a02a';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the gender of the user whose tweet got 535 retweets? [/INST]
|
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.RetweetCount = 535;
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Give the gender of the user who made the highest klout tweet on Wednesdays. [/INST]
|
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.Weekday = 'Wednesday' ORDER BY T1.Klout DESC LIMIT 1;
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: For the tweet which got the most likes, state the gender of the user who tweeted it. [/INST]
|
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID ORDER BY T1.Likes DESC LIMIT 1;
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: State the number of tweets from Michigan on Thursdays. [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Weekday = 'Thursday' AND T2.State = 'Michigan';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Which state was the tweet `tw-685681052912873473` from? Give the state code. [/INST]
|
SELECT T2.StateCode FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.TweetID = 'tw-685681052912873473';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the percentage of male Twitter users from Florida? [/INST]
|
SELECT SUM(CASE WHEN T3.Gender = 'Male' THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS percentage FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T3 ON T3.UserID = T1.UserID WHERE T2.State = 'Florida';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key
Country [ TEXT ]
State [ TEXT ]
StateCode [ TEXT ]
City [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the percentage of the tweets from California are positive? [/INST]
|
SELECT SUM(CASE WHEN T1.Sentiment > 0 THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS percentage FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE State = 'California';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the day of the week that tweet with ID tw-682712873332805633 was posted? [/INST]
|
SELECT Weekday FROM twitter WHERE TweetID = 'tw-682712873332805633';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many unique users have seen tweet with text `Happy New Year to all those AWS instances of ours!`? [/INST]
|
SELECT Reach FROM twitter WHERE text = 'Happy New Year to all those AWS instances of ours!';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Count the total number of tweet IDs in `en`. [/INST]
|
SELECT COUNT(DISTINCT TweetID) FROM twitter WHERE Lang = 'en';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Is 3751 the location ID for tweet with ID tw-682714048199311366? [/INST]
|
SELECT LocationID FROM twitter WHERE TweetID = 'tw-682714048199311366';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: How many tweets have been posted on Wednesday? [/INST]
|
SELECT COUNT(TweetID) FROM twitter WHERE Weekday = 'Wednesday';
|
[INST] Here is a database schema:
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: List down all of the texts posted on Twitter on Thursday. [/INST]
|
SELECT text FROM twitter WHERE Weekday = 'Thursday';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What is the gender of the user who posted a tweet with ID tw-682714583044243456? [/INST]
|
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.TweetID = 'tw-682714583044243456';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: List down the text of tweets posted by unknown gender users. [/INST]
|
SELECT T1.text FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Unknown';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: Calculate the total number of male tweet IDs. [/INST]
|
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Male';
|
[INST] Here is a database schema:
user :
UserID [ TEXT ] primary_key
Gender [ TEXT ]
twitter :
TweetID [ TEXT ] primary_key
Weekday [ TEXT ]
Hour [ INTEGER ]
Day [ INTEGER ]
Lang [ TEXT ]
IsReshare [ TEXT ]
Reach [ INTEGER ]
RetweetCount [ INTEGER ]
Likes [ INTEGER ]
Klout [ INTEGER ]
Sentiment [ REAL ]
text [ TEXT ]
LocationID [ INTEGER ] twitter.LocationID = location.LocationID
UserID [ TEXT ] twitter.UserID = user.UserID
Please write me a SQL statement that answers the following question: What gender of users posted the most tweets in `en`? [/INST]
|
SELECT T.Gender FROM ( SELECT T2.Gender, COUNT( text) AS num FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.Lang = 'en' GROUP BY T2.Gender ) T ORDER BY T.num DESC LIMIT 1;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.