db_id
stringclasses
146 values
question
stringlengths
3
224
sql
stringlengths
18
577
database_schema
stringclasses
146 values
insurance_fnol
Find the policy types more than 4 customers use. Show their type code.
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*) > 4
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the total and average amount of settlements.
SELECT sum(settlement_amount) , avg(settlement_amount) FROM settlements
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Return the sum and average of all settlement amounts.
SELECT sum(settlement_amount) , avg(settlement_amount) FROM settlements
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the name of services that have been used for more than 2 times in first notification of loss.
SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id = t2.service_id GROUP BY t1.service_id HAVING count(*) > 2
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Which services have been used more than twice in first notification of loss? Return the service name.
SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id = t2.service_id GROUP BY t1.service_id HAVING count(*) > 2
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What is the effective date of the claim that has the largest amount of total settlement?
SELECT t1.Effective_Date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id = t2.claim_id GROUP BY t1.claim_id ORDER BY sum(t2.settlement_amount) DESC LIMIT 1
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the claim that has the largest total settlement amount. Return the effective date of the claim.
SELECT t1.Effective_Date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id = t2.claim_id GROUP BY t1.claim_id ORDER BY sum(t2.settlement_amount) DESC LIMIT 1
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
How many policies are listed for the customer named "Dayana Robel"?
SELECT count(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Dayana Robel"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Count the total number of policies used by the customer named "Dayana Robel".
SELECT count(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Dayana Robel"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What is the name of the customer who has the most policies listed?
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Which customer uses the most policies? Give me the customer name.
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What are all the policy types of the customer named "Dayana Robel"?
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = "Dayana Robel"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Tell me the types of the policy used by the customer named "Dayana Robel".
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = "Dayana Robel"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What are all the policy types of the customer that has the most policies listed?
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1)
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
List all the policy types used by the customer enrolled in the most policies.
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1)
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
List all the services in the alphabetical order.
SELECT service_name FROM services ORDER BY service_name
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Give me a list of all the service names sorted alphabetically.
SELECT service_name FROM services ORDER BY service_name
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
How many services are there?
SELECT count(*) FROM services
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Count the total number of available services.
SELECT count(*) FROM services
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the names of users who do not have a first notification of loss record.
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Which customers do not have a first notification of loss record? Give me the customer names.
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the names of customers who have used either the service "Close a policy" or the service "Upgrade a policy".
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" OR t3.service_name = "Upgrade a policy"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Which customers have used the service named "Close a policy" or "Upgrade a policy"? Give me the customer names.
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" OR t3.service_name = "Upgrade a policy"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the names of customers who have used both the service "Close a policy" and the service "New policy application".
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "New policy application"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Which customers have used both the service named "Close a policy" and the service named "Upgrade a policy"? Give me the customer names.
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "New policy application"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the IDs of customers whose name contains "Diana".
SELECT customer_id FROM customers WHERE customer_name LIKE "%Diana%"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What are the IDs of customers who have "Diana" in part of their names?
SELECT customer_id FROM customers WHERE customer_name LIKE "%Diana%"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What are the maximum and minimum settlement amount on record?
SELECT max(settlement_amount) , min(settlement_amount) FROM settlements
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Find the maximum and minimum settlement amount.
SELECT max(settlement_amount) , min(settlement_amount) FROM settlements
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
List all the customers in increasing order of IDs.
SELECT customer_id , customer_name FROM customers ORDER BY customer_id ASC
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What is the ordered list of customer ids?
SELECT customer_id , customer_name FROM customers ORDER BY customer_id ASC
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
Retrieve the open and close dates of all the policies associated with the customer whose name contains "Diana"
SELECT t2.date_opened , t2.date_closed FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name LIKE "%Diana%"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
insurance_fnol
What are the open and close dates of all the policies used by the customer who have "Diana" in part of their names?
SELECT t2.date_opened , t2.date_closed FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name LIKE "%Diana%"
CREATE TABLE Customers ( Customer_ID INTEGER NOT NULL, Customer_name VARCHAR(40), PRIMARY KEY (Customer_ID) ) 3 rows from Customers table: Customer_ID Customer_name 194 America Jaskolski 214 Ellsworth Paucek 256 Mrs. Hanna Willms CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_name VARCHAR(40), PRIMARY KEY (Service_ID) ) 3 rows from Services table: Service_ID Service_name 1 New policy application 4 Close a policy 6 Change a policy CREATE TABLE Available_Policies ( Policy_ID INTEGER NOT NULL, policy_type_code CHAR(15), Customer_Phone VARCHAR(255), PRIMARY KEY (Policy_ID), UNIQUE (Policy_ID) ) 3 rows from Available_Policies table: Policy_ID policy_type_code Customer_Phone 246 Life Insurance +16(2)5838999222 257 Property Insurance 242.763.9214 300 Property Insurance 1-416-503-7735x94204 CREATE TABLE Customers_Policies ( Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Date_Opened DATE, Date_Closed DATE, PRIMARY KEY (Customer_ID, Policy_ID), FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID), FOREIGN KEY (Policy_ID) REFERENCES Available_Policies (Policy_ID) ) 3 rows from Customers_Policies table: Customer_ID Policy_ID Date_Opened Date_Closed 214 257 2016-11-19 2018-03-04 214 301 2016-04-12 2018-02-07 256 583 2016-07-22 2018-02-20 CREATE TABLE First_Notification_of_Loss ( FNOL_ID INTEGER NOT NULL, Customer_ID INTEGER NOT NULL, Policy_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, PRIMARY KEY (FNOL_ID), UNIQUE (FNOL_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID), FOREIGN KEY (Customer_ID, Policy_ID) REFERENCES Customers_Policies (Customer_ID,Policy_ID) ) 3 rows from First_Notification_of_Loss table: FNOL_ID Customer_ID Policy_ID Service_ID 532 214 257 6 1611 996 993 9 1722 996 879 6 CREATE TABLE Claims ( Claim_ID INTEGER NOT NULL, FNOL_ID INTEGER NOT NULL, Effective_Date DATE, PRIMARY KEY (Claim_ID), UNIQUE (Claim_ID), FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss (FNOL_ID) ) 3 rows from Claims table: Claim_ID FNOL_ID Effective_Date 134 1722 1973-08-18 145 1611 2014-10-19 228 532 1975-05-07 CREATE TABLE Settlements ( Settlement_ID INTEGER NOT NULL, Claim_ID INTEGER, Effective_Date DATE, Settlement_Amount REAL, PRIMARY KEY (Settlement_ID), UNIQUE (Settlement_ID), FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID) ) 3 rows from Settlements table: Settlement_ID Claim_ID Effective_Date Settlement_Amount 161 717 2009-11-20 6451.65 176 641 1971-06-29 1588.45 205 604 1978-09-09 9814.39
medicine_enzyme_interaction
How many kinds of enzymes are there?
SELECT count(*) FROM enzyme
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the total count of enzymes?
SELECT count(*) FROM enzyme
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
List the name of enzymes in descending lexicographical order.
SELECT name FROM enzyme ORDER BY name DESC
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names of enzymes in descending order?
SELECT name FROM enzyme ORDER BY name DESC
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
List the names and the locations that the enzymes can make an effect.
SELECT name , LOCATION FROM enzyme
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names and locations of all enzymes listed?
SELECT name , LOCATION FROM enzyme
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the maximum Online Mendelian Inheritance in Man (OMIM) value of the enzymes?
SELECT max(OMIM) FROM enzyme
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the maximum OMIM value in the database?
SELECT max(OMIM) FROM enzyme
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the product, chromosome and porphyria related to the enzymes which take effect at the location 'Cytosol'?
SELECT product , chromosome , porphyria FROM enzyme WHERE LOCATION = 'Cytosol'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the product, chromosome, and porphyria of the enzymes located at 'Cytosol'?
SELECT product , chromosome , porphyria FROM enzyme WHERE LOCATION = 'Cytosol'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names of enzymes who does not produce 'Heme'?
SELECT name FROM enzyme WHERE product != 'Heme'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names of enzymes whose product is not 'Heme'?
SELECT name FROM enzyme WHERE product != 'Heme'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names and trade names of the medicines which has 'Yes' value in the FDA record?
SELECT name , trade_name FROM medicine WHERE FDA_approved = 'Yes'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names and trade names of the medcines that are FDA approved?
SELECT name , trade_name FROM medicine WHERE FDA_approved = 'Yes'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names of enzymes in the medicine named 'Amisulpride' that can serve as an 'inhibitor'?
SELECT T1.name FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T1.id = T2.enzyme_id JOIN medicine AS T3 ON T2.medicine_id = T3.id WHERE T3.name = 'Amisulpride' AND T2.interaction_type = 'inhibitor'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names of the enzymes used in the medicine Amisulpride that acts as inhibitors?
SELECT T1.name FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T1.id = T2.enzyme_id JOIN medicine AS T3 ON T2.medicine_id = T3.id WHERE T3.name = 'Amisulpride' AND T2.interaction_type = 'inhibitor'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the ids and names of the medicine that can interact with two or more enzymes?
SELECT T1.id , T1.Name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING count(*) >= 2
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
For every medicine id, what are the names of the medicines that can interact with more than one enzyme?
SELECT T1.id , T1.Name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING count(*) >= 2
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the ids, names and FDA approval status of medicines in descending order of the number of enzymes that it can interact with.
SELECT T1.id , T1.Name , T1.FDA_approved FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id ORDER BY count(*) DESC
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the ids, names, and FDA approval status for medicines ordered by descending number of possible enzyme interactions?
SELECT T1.id , T1.Name , T1.FDA_approved FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id ORDER BY count(*) DESC
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the id and name of the enzyme with most number of medicines that can interact as 'activator'?
SELECT T1.id , T1.name FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T1.id = T2.enzyme_id WHERE T2.interaction_type = 'activitor' GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the id and name of the enzyme that can interact with the most medicines as an activator?
SELECT T1.id , T1.name FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T1.id = T2.enzyme_id WHERE T2.interaction_type = 'activitor' GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the interaction type of the enzyme named 'ALA synthase' and the medicine named 'Aripiprazole'?
SELECT T1.interaction_type FROM medicine_enzyme_interaction AS T1 JOIN medicine AS T2 ON T1.medicine_id = T2.id JOIN enzyme AS T3 ON T1.enzyme_id = T3.id WHERE T3.name = 'ALA synthase' AND T2.name = 'Aripiprazole'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the type of interaction for the enzyme named 'ALA synthase' and the medicine named 'Aripiprazole'?
SELECT T1.interaction_type FROM medicine_enzyme_interaction AS T1 JOIN medicine AS T2 ON T1.medicine_id = T2.id JOIN enzyme AS T3 ON T1.enzyme_id = T3.id WHERE T3.name = 'ALA synthase' AND T2.name = 'Aripiprazole'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the most common interaction type between enzymes and medicine? And how many are there?
SELECT interaction_type , count(*) FROM medicine_enzyme_interaction GROUP BY interaction_type ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the most common types of interactions between enzymes and medicine, and how many types are there?
SELECT interaction_type , count(*) FROM medicine_enzyme_interaction GROUP BY interaction_type ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
How many medicines have the FDA approval status 'No' ?
SELECT count(*) FROM medicine WHERE FDA_approved = 'No'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
How many medicines were not approved by the FDA?
SELECT count(*) FROM medicine WHERE FDA_approved = 'No'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
How many enzymes do not have any interactions?
SELECT count(*) FROM enzyme WHERE id NOT IN ( SELECT enzyme_id FROM medicine_enzyme_interaction );
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the count of enzymes without any interactions?
SELECT count(*) FROM enzyme WHERE id NOT IN ( SELECT enzyme_id FROM medicine_enzyme_interaction );
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What is the id and trade name of the medicines can interact with at least 3 enzymes?
SELECT T1.id , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 3
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the ids and trade names of the medicine that can interact with at least 3 enzymes?
SELECT T1.id , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 3
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the distinct name, location and products of the enzymes which has any 'inhibitor' interaction?
SELECT DISTINCT T1.name , T1.location , T1.product FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.enzyme_id = T1.id WHERE T2.interaction_type = 'inhibitor'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the different names, locations, and products of the enzymes that are capable inhibitor interactions?
SELECT DISTINCT T1.name , T1.location , T1.product FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.enzyme_id = T1.id WHERE T2.interaction_type = 'inhibitor'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
List the medicine name and trade name which can both interact as 'inhibitor' and 'activitor' with enzymes.
SELECT T1.name , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id WHERE interaction_type = 'inhibitor' INTERSECT SELECT T1.name , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id WHERE interaction_type = 'activitor'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the medicine and trade names that can interact as an inhibitor and activitor with enzymes?
SELECT T1.name , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id WHERE interaction_type = 'inhibitor' INTERSECT SELECT T1.name , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id WHERE interaction_type = 'activitor'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
Show the medicine names and trade names that cannot interact with the enzyme with product 'Heme'.
SELECT name , trade_name FROM medicine EXCEPT SELECT T1.name , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id JOIN enzyme AS T3 ON T3.id = T2.enzyme_id WHERE T3.product = 'Protoporphyrinogen IX'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the medicine and trade names that cannot interact with the enzyme with the product 'Heme'?
SELECT name , trade_name FROM medicine EXCEPT SELECT T1.name , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id JOIN enzyme AS T3 ON T3.id = T2.enzyme_id WHERE T3.product = 'Protoporphyrinogen IX'
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
How many distinct FDA approval statuses are there for the medicines?
SELECT count(DISTINCT FDA_approved) FROM medicine
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
How many different FDA approval statuses exist for medicines?
SELECT count(DISTINCT FDA_approved) FROM medicine
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
Which enzyme names have the substring "ALA"?
SELECT name FROM enzyme WHERE name LIKE "%ALA%"
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
What are the names of enzymes that include the string 'ALA'?
SELECT name FROM enzyme WHERE name LIKE "%ALA%"
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
find the number of medicines offered by each trade.
SELECT trade_name , count(*) FROM medicine GROUP BY trade_name
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
medicine_enzyme_interaction
How many medicines are offered by each trade name?
SELECT trade_name , count(*) FROM medicine GROUP BY trade_name
CREATE TABLE "medicine" ( "id" int, "name" text, "Trade_Name" text, "FDA_approved" text, primary key ("id") ) 3 rows from medicine table: id name Trade_Name FDA_approved 1 Amisulpride Solian No 2 Aripiprazole Abilify Yes 3 Asenapine Saphris Yes CREATE TABLE "enzyme" ( "id" int, "name" text, "Location" text, "Product" text, "Chromosome" text, "OMIM" int, "Porphyria" text, primary key ("id") ) 3 rows from enzyme table: id name Location Product Chromosome OMIM Porphyria 1 ALA synthase Mitochondrion Ξ΄-Aminolevulinic acid 3p21.1 125290 none 2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency 3 PBG deaminase Cytosol Hydroxymethyl bilane 11q23.3 176000 acute intermittent porphyria CREATE TABLE "medicine_enzyme_interaction" ( "enzyme_id" int, "medicine_id" int, "interaction_type" text, primary key ("enzyme_id", "medicine_id"), foreign key ("enzyme_id") references `enzyme`("id"), foreign key ("medicine_id") references `medicine`("id") ) 3 rows from medicine_enzyme_interaction table: enzyme_id medicine_id interaction_type 1 1 inhibitor 1 2 inhibitor 1 3 inhibitor
university_basketball
List all schools and their nicknames in the order of founded year.
SELECT school , nickname FROM university ORDER BY founded
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What are the different schools and their nicknames, ordered by their founding years?
SELECT school , nickname FROM university ORDER BY founded
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
List all public schools and their locations.
SELECT school , LOCATION FROM university WHERE affiliation = 'Public'
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What are the public schools and what are their locations?
SELECT school , LOCATION FROM university WHERE affiliation = 'Public'
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
When was the school with the largest enrollment founded?
SELECT founded FROM university ORDER BY enrollment DESC LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Return the founded year for the school with the largest enrollment.
SELECT founded FROM university ORDER BY enrollment DESC LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Find the founded year of the newest non public school.
SELECT founded FROM university WHERE affiliation != 'Public' ORDER BY founded DESC LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What is the founded year of the non public school that was founded most recently?
SELECT founded FROM university WHERE affiliation != 'Public' ORDER BY founded DESC LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
How many schools are in the basketball match?
SELECT count(DISTINCT school_id) FROM basketball_match
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Count the number of schools that have had basketball matches.
SELECT count(DISTINCT school_id) FROM basketball_match
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What is the highest acc percent score in the competition?
SELECT acc_percent FROM basketball_match ORDER BY acc_percent DESC LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Return the highest acc percent across all basketball matches.
SELECT acc_percent FROM basketball_match ORDER BY acc_percent DESC LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What is the primary conference of the school that has the lowest acc percent score in the competition?
SELECT t1.Primary_conference FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id ORDER BY t2.acc_percent LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Return the primary conference of the school with the lowest acc percentage score.
SELECT t1.Primary_conference FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id ORDER BY t2.acc_percent LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What is the team name and acc regular season score of the school that was founded for the longest time?
SELECT t2.team_name , t2.ACC_Regular_Season FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id ORDER BY t1.founded LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Return the name of the team and the acc during the regular season for the school that was founded the earliest.
SELECT t2.team_name , t2.ACC_Regular_Season FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id ORDER BY t1.founded LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Find the location and all games score of the school that has Clemson as its team name.
SELECT t2.All_Games , t1.location FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id WHERE team_name = 'Clemson'
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What are the all games score and location of the school called Clemson?
SELECT t2.All_Games , t1.location FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id WHERE team_name = 'Clemson'
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What are the average enrollment size of the universities that are founded before 1850?
SELECT avg(enrollment) FROM university WHERE founded < 1850
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Return the average enrollment of universities founded before 1850.
SELECT avg(enrollment) FROM university WHERE founded < 1850
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
Show the enrollment and primary_conference of the oldest college.
SELECT enrollment , primary_conference FROM university ORDER BY founded LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What are the enrollment and primary conference for the university which was founded the earliest?
SELECT enrollment , primary_conference FROM university ORDER BY founded LIMIT 1
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )
university_basketball
What is the total and minimum enrollment of all schools?
SELECT sum(enrollment) , min(enrollment) FROM university
CREATE TABLE "basketball_match" ( "Team_ID" int, "School_ID" int, "Team_Name" text, "ACC_Regular_Season" text, "ACC_Percent" text, "ACC_Home" text, "ACC_Road" text, "All_Games" text, "All_Games_Percent" int, "All_Home" text, "All_Road" text, "All_Neutral" text, PRIMARY KEY ("Team_ID"), FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`) ) 3 rows from basketball_match table: Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral 1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1 2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3 3 4 Clemson 10–6 .625 7–1 3–5 24–10 0.706 14–2 6–5 4–3 CREATE TABLE "university" ( "School_ID" int, "School" text, "Location" text, "Founded" real, "Affiliation" text, "Enrollment" real, "Nickname" text, "Primary_conference" text, PRIMARY KEY ("School_ID") ) 3 rows from university table: School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference 1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I ) 2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III ) 3 University of Rhode Island Kingston, RI 1892.0 Public 19095.0 Rams Atlantic 10 Conference ( D-I )