db_name
stringclasses 146
values | prompt
stringlengths 310
4.81k
|
---|---|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# Show the distinct venues of debates
#
### SQL:
#
# SELECT DISTINCT Venue FROM debate
#
### End.
|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# Show the names of people, and dates and venues of debates they are on the affirmative side.
#
### SQL:
#
# SELECT T3.Name , T2.Date , T2.Venue FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Affirmative = T3.People_ID
#
### End.
|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# Show the names of people, and dates and venues of debates they are on the negative side, ordered in ascending alphabetical order of name.
#
### SQL:
#
# SELECT T3.Name , T2.Date , T2.Venue FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Negative = T3.People_ID ORDER BY T3.Name ASC
#
### End.
|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# Show the names of people that are on affirmative side of debates with number of audience bigger than 200.
#
### SQL:
#
# SELECT T3.Name FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Affirmative = T3.People_ID WHERE T2.Num_of_Audience > 200
#
### End.
|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# Show the names of people and the number of times they have been on the affirmative side of debates.
#
### SQL:
#
# SELECT T2.Name , COUNT(*) FROM debate_people AS T1 JOIN people AS T2 ON T1.Affirmative = T2.People_ID GROUP BY T2.Name
#
### End.
|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# Show the names of people who have been on the negative side of debates at least twice.
#
### SQL:
#
# SELECT T2.Name FROM debate_people AS T1 JOIN people AS T2 ON T1.Negative = T2.People_ID GROUP BY T2.Name HAVING COUNT(*) >= 2
#
### End.
|
debate
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, District, Name, Party, Age )
# debate ( Debate_ID, Date, Venue, Num_of_Audience )
# debate_people ( Debate_ID, Affirmative, Negative, If_Affirmative_Win )
#
# debate_people.Negative can be joined with people.People_ID
# debate_people.Affirmative can be joined with people.People_ID
# debate_people.Debate_ID can be joined with debate.Debate_ID
#
### Question:
#
# List the names of people that have not been on the affirmative side of debates.
#
### SQL:
#
# SELECT Name FROM people WHERE People_id NOT IN (SELECT Affirmative FROM debate_people)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# List the names of all the customers in alphabetical order.
#
### SQL:
#
# SELECT customer_details FROM customers ORDER BY customer_details
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Sort the customer names in alphabetical order.
#
### SQL:
#
# SELECT customer_details FROM customers ORDER BY customer_details
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find all the policy type codes associated with the customer "Dayana Robel"
#
### SQL:
#
# SELECT policy_type_code FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_details = "Dayana Robel"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What are the type codes of the policies used by the customer "Dayana Robel"?
#
### SQL:
#
# SELECT policy_type_code FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_details = "Dayana Robel"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which type of policy is most frequently used? Give me the policy type code.
#
### SQL:
#
# SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the type code of the most frequently used policy.
#
### SQL:
#
# SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find all the policy types that are used by more than 2 customers.
#
### SQL:
#
# SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING count(*) > 2
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which types of policy are chosen by more than 2 customers? Give me the policy type codes.
#
### SQL:
#
# SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING count(*) > 2
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the total and average amount paid in claim headers.
#
### SQL:
#
# SELECT sum(amount_piad) , avg(amount_piad) FROM claim_headers
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What are the total amount and average amount paid in claim headers?
#
### SQL:
#
# SELECT sum(amount_piad) , avg(amount_piad) FROM claim_headers
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the total amount claimed in the most recently created document.
#
### SQL:
#
# SELECT sum(t1.amount_claimed) FROM claim_headers AS t1 JOIN claims_documents AS t2 ON t1.claim_header_id = t2.claim_id WHERE t2.created_date = (SELECT created_date FROM claims_documents ORDER BY created_date LIMIT 1)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# How much amount in total were claimed in the most recently created document?
#
### SQL:
#
# SELECT sum(t1.amount_claimed) FROM claim_headers AS t1 JOIN claims_documents AS t2 ON t1.claim_header_id = t2.claim_id WHERE t2.created_date = (SELECT created_date FROM claims_documents ORDER BY created_date LIMIT 1)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What is the name of the customer who has made the largest amount of claim in a single claim?
#
### SQL:
#
# SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_claimed = (SELECT max(amount_claimed) FROM claim_headers)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customer made the largest amount of claim in a single claim? Return the customer details.
#
### SQL:
#
# SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_claimed = (SELECT max(amount_claimed) FROM claim_headers)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What is the name of the customer who has made the minimum amount of payment in one claim?
#
### SQL:
#
# SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT min(amount_piad) FROM claim_headers)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customer made the smallest amount of claim in one claim? Return the customer details.
#
### SQL:
#
# SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT min(amount_piad) FROM claim_headers)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the names of customers who have no policies associated.
#
### SQL:
#
# SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What are the names of customers who do not have any policies?
#
### SQL:
#
# SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# How many claim processing stages are there in total?
#
### SQL:
#
# SELECT count(*) FROM claims_processing_stages
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the number of distinct stages in claim processing.
#
### SQL:
#
# SELECT count(*) FROM claims_processing_stages
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What is the name of the claim processing stage that most of the claims are on?
#
### SQL:
#
# SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which claim processing stage has the most claims? Show the claim status name.
#
### SQL:
#
# SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the names of customers whose name contains "Diana".
#
### SQL:
#
# SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customers have the substring "Diana" in their names? Return the customer details.
#
### SQL:
#
# SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the names of the customers who have an deputy policy.
#
### SQL:
#
# SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = "Deputy"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customers have an insurance policy with the type code "Deputy"? Give me the customer details.
#
### SQL:
#
# SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = "Deputy"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the names of customers who either have an deputy policy or uniformed policy.
#
### SQL:
#
# SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = "Deputy" OR t1.policy_type_code = "Uniform"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customers have an insurance policy with the type code "Deputy" or "Uniform"? Return the customer details.
#
### SQL:
#
# SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = "Deputy" OR t1.policy_type_code = "Uniform"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the names of all the customers and staff members.
#
### SQL:
#
# SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What are the names of the customers and staff members?
#
### SQL:
#
# SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the number of records of each policy type and its type code.
#
### SQL:
#
# SELECT policy_type_code , count(*) FROM policies GROUP BY policy_type_code
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# For each policy type, return its type code and its count in the record.
#
### SQL:
#
# SELECT policy_type_code , count(*) FROM policies GROUP BY policy_type_code
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the name of the customer that has been involved in the most policies.
#
### SQL:
#
# SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY count(*) DESC LIMIT 1
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customer have the most policies? Give me the customer details.
#
### SQL:
#
# SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY count(*) DESC LIMIT 1
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# What is the description of the claim status "Open"?
#
### SQL:
#
# SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = "Open"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the description of the claim status "Open".
#
### SQL:
#
# SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = "Open"
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# How many distinct claim outcome codes are there?
#
### SQL:
#
# SELECT count(DISTINCT claim_outcome_code) FROM claims_processing
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Count the number of distinct claim outcome codes.
#
### SQL:
#
# SELECT count(DISTINCT claim_outcome_code) FROM claims_processing
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Which customer is associated with the latest policy?
#
### SQL:
#
# SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT max(start_date) FROM policies)
#
### End.
|
insurance_and_eClaims
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( Customer_ID, Customer_Details )
# Staff ( Staff_ID, Staff_Details )
# Policies ( Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date )
# Claim_Headers ( Claim_Header_ID, Claim_Status_Code, Claim_Type_Code, Policy_ID, Date_of_Claim, Date_of_Settlement, Amount_Claimed, Amount_Piad )
# Claims_Documents ( Claim_ID, Document_Type_Code, Created_by_Staff_ID, Created_Date )
# Claims_Processing_Stages ( Claim_Stage_ID, Next_Claim_Stage_ID, Claim_Status_Name, Claim_Status_Description )
# Claims_Processing ( Claim_Processing_ID, Claim_ID, Claim_Outcome_Code, Claim_Stage_ID, Staff_ID )
#
# Policies.Customer_ID can be joined with Customers.Customer_ID
# Claim_Headers.Policy_ID can be joined with Policies.Policy_ID
# Claims_Documents.Created_by_Staff_ID can be joined with Staff.Staff_ID
# Claims_Documents.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
# Claims_Processing.Staff_ID can be joined with Staff.Staff_ID
# Claims_Processing.Claim_ID can be joined with Claim_Headers.Claim_Header_ID
#
### Question:
#
# Find the customer who started a policy most recently.
#
### SQL:
#
# SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT max(start_date) FROM policies)
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the number of accounts.
#
### SQL:
#
# SELECT count(*) FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many accounts are there?
#
### SQL:
#
# SELECT count(*) FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many customers have opened an account?
#
### SQL:
#
# SELECT count(DISTINCT customer_id) FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of customers who have an account.
#
### SQL:
#
# SELECT count(DISTINCT customer_id) FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the id, the date of account opened, the account name, and other account detail for all accounts.
#
### SQL:
#
# SELECT account_id , date_account_opened , account_name , other_account_details FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the ids, date opened, name, and other details for all accounts?
#
### SQL:
#
# SELECT account_id , date_account_opened , account_name , other_account_details FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the id, the account name, and other account details for all accounts by the customer with first name 'Meaghan'.
#
### SQL:
#
# SELECT T1.account_id , T1.date_account_opened , T1.account_name , T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan'
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the ids, names, dates of opening, and other details for accounts corresponding to the customer with the first name "Meaghan"?
#
### SQL:
#
# SELECT T1.account_id , T1.date_account_opened , T1.account_name , T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan'
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the account name and other account detail for all accounts by the customer with first name Meaghan and last name Keeling.
#
### SQL:
#
# SELECT T1.account_name , T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Meaghan" AND T2.customer_last_name = "Keeling"
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the names and other details for accounts corresponding to the customer named Meaghan Keeling?
#
### SQL:
#
# SELECT T1.account_name , T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Meaghan" AND T2.customer_last_name = "Keeling"
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the first name and last name for the customer with account name 900.
#
### SQL:
#
# SELECT T2.customer_first_name , T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = "900"
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the full names of customers with the account name 900?
#
### SQL:
#
# SELECT T2.customer_first_name , T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = "900"
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many customers don't have an account?
#
### SQL:
#
# SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of customers who do not have an account.
#
### SQL:
#
# SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the unique first names, last names, and phone numbers for all customers with any account.
#
### SQL:
#
# SELECT DISTINCT T1.customer_first_name , T1.customer_last_name , T1.phone_number FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the distinct first names, last names, and phone numbers for customers with accounts?
#
### SQL:
#
# SELECT DISTINCT T1.customer_first_name , T1.customer_last_name , T1.phone_number FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show customer ids who don't have an account.
#
### SQL:
#
# SELECT customer_id FROM Customers EXCEPT SELECT customer_id FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the customer ids for customers who do not have an account?
#
### SQL:
#
# SELECT customer_id FROM Customers EXCEPT SELECT customer_id FROM Accounts
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many accounts does each customer have? List the number and customer id.
#
### SQL:
#
# SELECT count(*) , customer_id FROM Accounts GROUP BY customer_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of accounts corresponding to each customer id.
#
### SQL:
#
# SELECT count(*) , customer_id FROM Accounts GROUP BY customer_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the customer id, first and last name with most number of accounts.
#
### SQL:
#
# SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Return the id and full name of the customer with the most accounts.
#
### SQL:
#
# SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show id, first name and last name for all customers and the number of accounts.
#
### SQL:
#
# SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name , count(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the the full names and ids for all customers, and how many accounts does each have?
#
### SQL:
#
# SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name , count(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show first name and id for all customers with at least 2 accounts.
#
### SQL:
#
# SELECT T2.customer_first_name , T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the first names and ids for customers who have two or more accounts?
#
### SQL:
#
# SELECT T2.customer_first_name , T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the number of customers.
#
### SQL:
#
# SELECT count(*) FROM Customers
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of customers.
#
### SQL:
#
# SELECT count(*) FROM Customers
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the number of customers for each gender.
#
### SQL:
#
# SELECT gender , count(*) FROM Customers GROUP BY gender
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many customers are there of each gender?
#
### SQL:
#
# SELECT gender , count(*) FROM Customers GROUP BY gender
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many transactions do we have?
#
### SQL:
#
# SELECT count(*) FROM Financial_transactions
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of transactions.
#
### SQL:
#
# SELECT count(*) FROM Financial_transactions
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many transaction does each account have? Show the number and account id.
#
### SQL:
#
# SELECT count(*) , account_id FROM Financial_transactions
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of financial transactions that correspond to each account id.
#
### SQL:
#
# SELECT count(*) , account_id FROM Financial_transactions
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many transaction does account with name 337 have?
#
### SQL:
#
# SELECT count(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id WHERE T2.account_name = "337"
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of financial transactions that the account with the name 337 has.
#
### SQL:
#
# SELECT count(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id WHERE T2.account_name = "337"
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the average, minimum, maximum, and total transaction amount?
#
### SQL:
#
# SELECT avg(transaction_amount) , min(transaction_amount) , max(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Return the average, minimum, maximum, and total transaction amounts.
#
### SQL:
#
# SELECT avg(transaction_amount) , min(transaction_amount) , max(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show ids for all transactions whose amounts are greater than the average.
#
### SQL:
#
# SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT avg(transaction_amount) FROM Financial_transactions)
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the ids for transactions that have an amount greater than the average amount of a transaction?
#
### SQL:
#
# SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT avg(transaction_amount) FROM Financial_transactions)
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the transaction types and the total amount of transactions.
#
### SQL:
#
# SELECT transaction_type , sum(transaction_amount) FROM Financial_transactions GROUP BY transaction_type
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are total transaction amounts for each transaction type?
#
### SQL:
#
# SELECT transaction_type , sum(transaction_amount) FROM Financial_transactions GROUP BY transaction_type
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the account name, id and the number of transactions for each account.
#
### SQL:
#
# SELECT T2.account_name , T1.account_id , count(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Return the names and ids of each account, as well as the number of transactions.
#
### SQL:
#
# SELECT T2.account_name , T1.account_id , count(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the account id with most number of transactions.
#
### SQL:
#
# SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the id of the account with the most transactions?
#
### SQL:
#
# SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the account id and name with at least 4 transactions.
#
### SQL:
#
# SELECT T1.account_id , T2.account_name FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id HAVING count(*) >= 4
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the ids and names of accounts with 4 or more transactions?
#
### SQL:
#
# SELECT T1.account_id , T2.account_name FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id HAVING count(*) >= 4
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show all product sizes.
#
### SQL:
#
# SELECT DISTINCT product_size FROM Products
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the different product sizes?
#
### SQL:
#
# SELECT DISTINCT product_size FROM Products
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show all product colors.
#
### SQL:
#
# SELECT DISTINCT product_color FROM Products
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the different product colors?
#
### SQL:
#
# SELECT DISTINCT product_color FROM Products
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the invoice number and the number of transactions for each invoice.
#
### SQL:
#
# SELECT invoice_number , count(*) FROM Financial_transactions GROUP BY invoice_number
#
### End.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.