schema
stringlengths
144
5.45k
question
stringlengths
16
224
query
stringlengths
18
577
hardness
stringclasses
5 values
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
How many customers are there in the customer type with the most customers?
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
hard
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Count the number of customers that have the customer type that is most common.
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
hard
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
What is the last name of the staff who has handled the first ever complaint?
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
hard
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Return the last name of the staff member who handled the complaint with the earliest date raised.
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
hard
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
How many distinct complaint type codes are there in the database?
SELECT count(DISTINCT complaint_type_code) FROM complaints
easy
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Count the number of different complaint type codes.
SELECT count(DISTINCT complaint_type_code) FROM complaints
easy
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Find the address line 1 and 2 of the customer with email "[email protected]".
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "[email protected]"
medium
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
What are lines 1 and 2 of the addressed of the customer with the email "[email protected]"?
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "[email protected]"
medium
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Find the number of complaints with Product Failure type for each complaint status.
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
medium
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Of complaints with the type code "Product Failure", how many had each different status code?
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
medium
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
What is first names of the top 5 staff who have handled the greatest number of complaints?
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
extra
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Return the first names of the 5 staff members who have handled the most complaints.
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
extra
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Which state has the most customers?
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
hard
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number);
Give the state that has the most customers.
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
How many submissions are there?
SELECT count(*) FROM submission
easy
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Count the number of submissions.
SELECT count(*) FROM submission
easy
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
List the authors of submissions in ascending order of scores.
SELECT Author FROM submission ORDER BY Scores ASC
easy
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Find the author for each submission and list them in ascending order of submission score.
SELECT Author FROM submission ORDER BY Scores ASC
easy
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
What are the authors of submissions and their colleges?
SELECT Author , College FROM submission
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
For each submission, show the author and their affiliated college.
SELECT Author , College FROM submission
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the names of authors from college "Florida" or "Temple"
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Which authors with submissions are from college "Florida" or "Temple"?
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
What is the average score of submissions?
SELECT avg(Scores) FROM submission
easy
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Compute the average score of submissions.
SELECT avg(Scores) FROM submission
easy
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
What is the author of the submission with the highest score?
SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Find the author who achieved the highest score in a submission.
SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show different colleges along with the number of authors of submission from each college.
SELECT College , COUNT(*) FROM submission GROUP BY College
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
For each college, return the college name and the count of authors with submissions from that college.
SELECT College , COUNT(*) FROM submission GROUP BY College
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the most common college of authors of submissions.
SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Which college has the most authors with submissions?
SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the colleges that have both authors with submission score larger than 90 and authors with submission score smaller than 80.
SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Which colleges have both authors with submission score above 90 and authors with submission score below 80?
SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the authors of submissions and the acceptance results of their submissions.
SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
For each submission, find its author and acceptance result.
SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the result of the submission with the highest score.
SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Which submission received the highest score in acceptance result. Show me the result.
SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show each author and the number of workshops they submitted to.
SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
How many workshops did each author submit to? Return the author name and the number of workshops.
SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the authors who have submissions to more than one workshop.
SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Which authors have submitted to more than one workshop?
SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Show the date and venue of each workshop in ascending alphabetical order of the venue.
SELECT Date , Venue FROM workshop ORDER BY Venue
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Sort the each workshop in alphabetical order of the venue. Return the date and venue of each workshop.
SELECT Date , Venue FROM workshop ORDER BY Venue
medium
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
List the authors who do not have submission to any workshop.
SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance)
hard
CREATE TABLE workshop (Workshop_ID number, Date text, Venue text, Name text); CREATE TABLE submission (Submission_ID number, Scores number, Author text, College text); CREATE TABLE Acceptance (Submission_ID number, Workshop_ID number, Result text);
Which authors did not submit to any workshop?
SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance)
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Find the number of investors in total.
SELECT count(*) FROM INVESTORS
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show all investor details.
SELECT Investor_details FROM INVESTORS
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show all distinct lot details.
SELECT DISTINCT lot_details FROM LOTS
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the maximum amount of transaction.
SELECT max(amount_of_transaction) FROM TRANSACTIONS
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show all date and share count of transactions.
SELECT date_of_transaction , share_count FROM TRANSACTIONS
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What is the total share of transactions?
SELECT sum(share_count) FROM TRANSACTIONS
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show all transaction ids with transaction code 'PUR'.
SELECT transaction_id FROM TRANSACTIONS WHERE transaction_type_code = 'PUR'
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show all dates of transactions whose type code is "SALE".
SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average amount of transactions with type code "SALE".
SELECT avg(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the description of transaction type with code "PUR".
SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = "PUR"
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the minimum amount of transactions whose type code is "PUR" and whose share count is bigger than 50.
SELECT min(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the maximum share count of transactions where the amount is smaller than 10000
SELECT max(share_count) FROM TRANSACTIONS WHERE amount_of_transaction < 10000
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000.
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the transaction type descriptions and dates if the share count is smaller than 10.
SELECT T1.transaction_type_description , T2.date_of_transaction FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code WHERE T2.share_count < 10
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show details of all investors if they make any transaction with share count greater than 100.
SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
How many distinct transaction types are used in the transactions?
SELECT COUNT(DISTINCT transaction_type_code) FROM TRANSACTIONS
easy
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Return the lot details and investor ids.
SELECT lot_details , investor_id FROM LOTS
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Return the lot details of lots that belong to investors with details "l"?
SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l"
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the purchase details of transactions with amount bigger than 10000?
SELECT T1.purchase_details FROM PURCHASES AS T1 JOIN TRANSACTIONS AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the sale details and dates of transactions with amount smaller than 3000?
SELECT T1.sales_details , T2.date_of_transaction FROM SALES AS T1 JOIN TRANSACTIONS AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the lot details of lots associated with transactions with share count smaller than 50?
SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count < 50
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the lot details of lots associated with transactions whose share count is bigger than 100 and whose type code is "PUR"?
SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count > 100 AND T3.transaction_type_code = "PUR"
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average transaction amount for different transaction types.
SELECT transaction_type_code , avg(amount_of_transaction) FROM TRANSACTIONS GROUP BY transaction_type_code
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the maximum and minimum share count of different transaction types.
SELECT transaction_type_code , max(share_count) , min(share_count) FROM TRANSACTIONS GROUP BY transaction_type_code
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average share count of transactions for different investors.
SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average share count of transactions each each investor, ordered by average share count.
SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY avg(share_count)
extra
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average amount of transactions for different investors.
SELECT investor_id , avg(amount_of_transaction) FROM TRANSACTIONS GROUP BY investor_id
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average amount of transactions for different lots.
SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the average amount of transactions for different lots, ordered by average amount of transactions.
SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id ORDER BY avg(amount_of_transaction)
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the number of transactions with transaction type code "SALE" for different investors if it is larger than 0.
SELECT investor_id , COUNT(*) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" GROUP BY investor_id
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the number of transactions for different investors.
SELECT investor_id , COUNT(*) FROM TRANSACTIONS GROUP BY investor_id
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the transaction type code that occurs the fewest times.
SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) ASC LIMIT 1
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the transaction type code that occurs the most frequently.
SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the description of the transaction type that occurs most frequently.
SELECT T1.transaction_type_description FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code GROUP BY T1.transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
extra
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the id and details of the investor that has the largest number of transactions.
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 1
extra
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the id and details for the investors who have the top 3 number of transactions.
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 3
extra
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the ids of the investors who have at least two transactions.
SELECT T2.investor_id FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id HAVING COUNT(*) >= 2
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
Show the ids and details of the investors who have at least two transactions with type code "SALE".
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" GROUP BY T2.investor_id HAVING COUNT(*) >= 2
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the dates of transactions with at least 100 share count or amount bigger than 100?
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100
medium
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the details of all sales and purchases?
SELECT sales_details FROM sales UNION SELECT purchase_details FROM purchases
hard
CREATE TABLE Investors (investor_id number, Investor_details text); CREATE TABLE Lots (lot_id number, investor_id number, lot_details text); CREATE TABLE Ref_Transaction_Types (transaction_type_code text, transaction_type_description text); CREATE TABLE Transactions (transaction_id number, investor_id number, transaction_type_code text, date_of_transaction time, amount_of_transaction number, share_count text, other_details text); CREATE TABLE Sales (sales_transaction_id number, sales_details text); CREATE TABLE Purchases (purchase_transaction_id number, purchase_details text); CREATE TABLE Transactions_Lots (transaction_id number, lot_id number);
What are the details of the lots which are not used in any transactions?
SELECT lot_details FROM Lots EXCEPT SELECT T1.lot_details FROM Lots AS T1 JOIN transactions_lots AS T2 ON T1.lot_id = T2.lot_id
hard
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
How many available hotels are there in total?
SELECT count(*) FROM HOTELS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Find the total number of available hotels.
SELECT count(*) FROM HOTELS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What are the price ranges of hotels?
SELECT price_range FROM HOTELS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Tell me the price ranges for all the hotels.
SELECT price_range FROM HOTELS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Show all distinct location names.
SELECT DISTINCT Location_Name FROM LOCATIONS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What are the distinct location names?
SELECT DISTINCT Location_Name FROM LOCATIONS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Show the names and details of all the staff members.
SELECT Name , Other_Details FROM Staff
medium
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What is the name and detail of each staff member?
SELECT Name , Other_Details FROM Staff
medium
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Show details of all visitors.
SELECT Tourist_Details FROM VISITORS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What is the detail of each visitor?
SELECT Tourist_Details FROM VISITORS
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Show the price ranges of hotels with 5 star ratings.
SELECT price_range FROM HOTELS WHERE star_rating_code = "5"
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What are the price ranges of five star hotels?
SELECT price_range FROM HOTELS WHERE star_rating_code = "5"
easy
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
Show the average price range of hotels that have 5 star ratings and allow pets.
SELECT avg(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1
medium
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What is the average price range of five star hotels that allow pets?
SELECT avg(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1
medium
CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_code text, star_rating_description text); CREATE TABLE Locations (Location_ID number, Location_Name text, Address text, Other_Details text); CREATE TABLE Ref_Attraction_Types (Attraction_Type_Code text, Attraction_Type_Description text); CREATE TABLE Visitors (Tourist_ID number, Tourist_Details text); CREATE TABLE Features (Feature_ID number, Feature_Details text); CREATE TABLE Hotels (hotel_id number, star_rating_code text, pets_allowed_yn text, price_range number, other_hotel_details text); CREATE TABLE Tourist_Attractions (Tourist_Attraction_ID number, Attraction_Type_Code text, Location_ID number, How_to_Get_There text, Name text, Description text, Opening_Hours text, Other_Details text); CREATE TABLE Street_Markets (Market_ID number, Market_Details text); CREATE TABLE Shops (Shop_ID number, Shop_Details text); CREATE TABLE Museums (Museum_ID number, Museum_Details text); CREATE TABLE Royal_Family (Royal_Family_ID number, Royal_Family_Details text); CREATE TABLE Theme_Parks (Theme_Park_ID number, Theme_Park_Details text); CREATE TABLE Visits (Visit_ID number, Tourist_Attraction_ID number, Tourist_ID number, Visit_Date time, Visit_Details text); CREATE TABLE Photos (Photo_ID number, Tourist_Attraction_ID number, Name text, Description text, Filename text, Other_Details text); CREATE TABLE Staff (Staff_ID number, Tourist_Attraction_ID number, Name text, Other_Details text); CREATE TABLE Tourist_Attraction_Features (Tourist_Attraction_ID number, Feature_ID number);
What is the address of the location "UK Gallery"?
SELECT Address FROM LOCATIONS WHERE Location_Name = "UK Gallery"
easy