SQL
stringlengths 18
577
| question
stringlengths 317
11.5k
|
---|---|
SELECT shipping_agent_name FROM Ref_Shipping_Agents;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What are the shipping agent names?
|
SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the shipping agent code of shipping agent UPS?
|
SELECT role_code FROM ROLES;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What are all role codes?
|
SELECT role_description FROM ROLES WHERE role_code = "ED";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the description of role code ED?
|
SELECT count(*) FROM Employees;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. How many employees do we have?
|
SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the role of the employee named Koby?
|
SELECT document_id , receipt_date FROM Documents;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List all document ids and receipt dates of documents.
|
SELECT T1.role_description , T2.role_code , count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. How many employees does each role have? List role description, id and number of employees.
|
SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id) > 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List roles that have more than one employee. List the role description and number of employees.
|
SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the document status description of the document with id 1?
|
SELECT count(*) FROM Documents WHERE document_status_code = "done";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. How many documents have the status code done?
|
SELECT document_type_code FROM Documents WHERE document_id = 2;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List the document type code for the document with the id 2.
|
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List the document ids for any documents with the status code done and the type code paper.
|
SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the name of the shipping agent of the document with id 2?
|
SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. How many documents were shipped by USPS?
|
SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) DESC LIMIT 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.
|
SELECT receipt_date FROM Documents WHERE document_id = 3;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the receipt date of the document with id 3?
|
SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What address was the document with id 4 mailed to?
|
SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is the mail date of the document with id 7?
|
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.
|
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.
|
SELECT draft_details FROM Document_Drafts WHERE document_id = 7;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. What is draft detail of the document with id 7?
|
SELECT count(*) FROM Draft_Copies WHERE document_id = 2;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. How many draft copies does the document with id 2 have?
|
SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. Which document has the most draft copies? List its document id and number of draft copies.
|
SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*) > 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. Which documents have more than 1 draft copies? List document id and number of draft copies.
|
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List all employees in the circulation history of the document with id 1. List the employee's name.
|
SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. List the employees who have not showed up in any circulation history of documents. List the employee's name.
|
SELECT Employees.employee_name , count(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) DESC LIMIT 1;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.
|
SELECT document_id , count(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id;
|
Given the Table reference document types having columns as document_type_code has datatype text, document_type_description has datatype text which has document_type_code and Given the Table roles having columns as role_code has datatype text, role_description has datatype text which has role_code and Given the Table addresses having columns as address_id has datatype number, address_details has datatype text which has address_id and Given the Table reference document status having columns as document_status_code has datatype text, document_status_description has datatype text which has document_status_code and Given the Table reference shipping agents having columns as shipping_agent_code has datatype text, shipping_agent_name has datatype text, shipping_agent_description has datatype text which has shipping_agent_code and Given the Table documents having columns as document_id has datatype number, document_status_code has datatype text, document_type_code has datatype text, shipping_agent_code has datatype text, receipt_date has datatype time, receipt_number has datatype text, other_details has datatype text which has document_id and Given the Table employees having columns as employee_id has datatype number, role_code has datatype text, employee_name has datatype text, other_details has datatype text which has employee_id and Given the Table document drafts having columns as document_id has datatype number, draft_number has datatype number, draft_details has datatype text which has document_id and Given the Table draft copies having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number which has document_id and Given the Table circulation history having columns as document_id has datatype number, draft_number has datatype number, copy_number has datatype number, employee_id has datatype number which has document_id and Given the Table documents mailed having columns as document_id has datatype number, mailed_to_address_id has datatype number, mailing_date has datatype time which has document_id. Answer the question by writing the appropriate SQL code. For each document, list the number of employees who have showed up in the circulation history of that document. List the document ids and number of employees.
|
SELECT dname FROM department ORDER BY mgr_start_date
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. List all department names ordered by their starting date.
|
SELECT Dependent_name FROM dependent WHERE relationship = 'Spouse'
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. find all dependent names who have a spouse relation with some employee.
|
SELECT count(*) FROM dependent WHERE sex = 'F'
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. how many female dependents are there?
|
SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber = t2.dnumber WHERE t2.dlocation = 'Houston'
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. Find the names of departments that are located in Houston.
|
SELECT fname , lname FROM employee WHERE salary > 30000
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. Return the first names and last names of employees who earn more than 30000 in salary.
|
SELECT count(*) , sex FROM employee WHERE salary < 50000 GROUP BY sex
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. Find the number of employees of each gender whose salary is lower than 50000.
|
SELECT fname , lname , address FROM employee ORDER BY Bdate
|
Given the Table works on having columns as Essn has datatype number, Pno has datatype number, Hours has datatype number which has Essn and Given the Table employee having columns as Fname has datatype text, Minit has datatype text, Lname has datatype text, Ssn has datatype number, Bdate has datatype text, Address has datatype text, Sex has datatype text, Salary has datatype number, Super_ssn has datatype number, Dno has datatype number which has Ssn and Given the Table department having columns as Dname has datatype text, Dnumber has datatype number, Mgr_ssn has datatype number, Mgr_start_date has datatype text which has Dnumber and Given the Table project having columns as Pname has datatype text, Pnumber has datatype number, Plocation has datatype text, Dnum has datatype number which has Pnumber and Given the Table dependent having columns as Essn has datatype number, Dependent_name has datatype text, Sex has datatype text, Bdate has datatype text, Relationship has datatype text which has Essn and Given the Table department locations having columns as Dnumber has datatype number, Dlocation has datatype text which has Dnumber. Answer the question by writing the appropriate SQL code. list the first and last names, and the addresses of all employees in the ascending order of their birth date.
|
SELECT T1.event_details FROM EVENTS AS T1 JOIN Services AS T2 ON T1.Service_ID = T2.Service_ID WHERE T2.Service_Type_Code = 'Marriage'
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. what are the event details of the services that have the type code 'Marriage'?
|
SELECT T1.event_id , T1.event_details FROM EVENTS AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID = T2.Event_ID GROUP BY T1.Event_ID HAVING count(*) > 1
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. What are the ids and details of events that have more than one participants?
|
SELECT T1.Participant_ID , T1.Participant_Type_Code , count(*) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID GROUP BY T1.Participant_ID
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. How many events have each participants attended? List the participant id, type and the number.
|
SELECT Participant_ID , Participant_Type_Code , Participant_Details FROM Participants
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. What are all the the participant ids, type code and details?
|
SELECT count(*) FROM participants WHERE participant_type_code = 'Organizer'
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. How many participants belong to the type 'Organizer'?
|
SELECT service_type_code FROM services ORDER BY service_type_code
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. List the type of the services in alphabetical order.
|
SELECT service_id , event_details FROM EVENTS
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. List the service id and details for the events.
|
SELECT count(*) FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE T1.participant_details LIKE '%Dr.%'
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. How many events had participants whose details had the substring 'Dr.'
|
SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY count(*) DESC LIMIT 1
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. What is the most common participant type?
|
SELECT T3.service_id , T4.Service_Type_Code FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID JOIN EVENTS AS T3 ON T2.Event_ID = T3.Event_ID JOIN services AS T4 ON T3.service_id = T4.service_id GROUP BY T3.service_id ORDER BY count(*) ASC LIMIT 1
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. Which service id and type has the least number of participants?
|
SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY count(*) DESC LIMIT 1
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. What is the id of the event with the most participants?
|
SELECT event_id FROM EVENTS EXCEPT SELECT T1.event_id FROM Participants_in_Events AS T1 JOIN Participants AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE Participant_Details = 'Kenyatta Kuhn'
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. Which events id does not have any participant with detail 'Kenyatta Kuhn'?
|
SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Success' INTERSECT SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Fail'
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. Which services type had both successful and failure event details?
|
SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events)
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. How many events did not have any participants?
|
SELECT count(DISTINCT participant_id) FROM participants_in_Events
|
Given the Table services having columns as Service_ID has datatype number, Service_Type_Code has datatype text which has Service_ID and Given the Table participants having columns as Participant_ID has datatype number, Participant_Type_Code has datatype text, Participant_Details has datatype text which has Participant_ID and Given the Table events having columns as Event_ID has datatype number, Service_ID has datatype number, Event_Details has datatype text which has Event_ID and Given the Table participants in events having columns as Event_ID has datatype number, Participant_ID has datatype number which has Event_ID. Answer the question by writing the appropriate SQL code. What are all the distinct participant ids who attended any events?
|
SELECT name FROM races ORDER BY date DESC LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the name of the race held most recently?
|
SELECT name FROM races ORDER BY date DESC LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the name of the race that occurred most recently?
|
SELECT name , date FROM races ORDER BY date DESC LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the name and date of the most recent race?
|
SELECT name , date FROM races ORDER BY date DESC LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the name and date of the race that occurred most recently?
|
SELECT name FROM races WHERE YEAR = 2017
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find the names of all races held in 2017.
|
SELECT name FROM races WHERE YEAR = 2017
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the names of all the races that occurred in the year 2017?
|
SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find the distinct names of all races held between 2014 and 2017?
|
SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the unique names of all race held between 2014 and 2017?
|
SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds?
|
SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the forenames and surnames of all unique drivers who had a lap time of less than 93000 milliseconds?
|
SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds?
|
SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the different driver ids and nationalities of all drivers who had a laptime of more than 100000 milliseconds?
|
SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the forename and surname of the driver who has the smallest laptime?
|
SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the forename and surname of the driver with the shortest laptime?
|
SELECT T1.driverid , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds DESC LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the id and family name of the driver who has the longest laptime?
|
SELECT T1.driverid , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds DESC LIMIT 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the id and last name of the driver with the longest laptime?
|
SELECT T1.driverid , T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE POSITION = '1' GROUP BY T1.driverid HAVING count(*) >= 2
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice?
|
SELECT T1.driverid , T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE POSITION = '1' GROUP BY T1.driverid HAVING count(*) >= 2
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the id, first name, and last name of the driver who was in the first position for laptime at least twice?
|
SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. How many drivers participated in the race Australian Grand Prix held in 2009?
|
SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. How many drivers were in the Australian Grand Prix held in 2009?
|
SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 )
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. How many drivers did not participate in the races held in 2009?
|
SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 )
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. How many drivers did not race in 2009?
|
SELECT T2.name , T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Give me a list of names and years of races that had any driver whose forename is Lewis?
|
SELECT T2.name , T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the names and years of all races that had a driver with the last name Lewis?
|
SELECT forename , surname FROM drivers WHERE nationality = "German"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find the forename and surname of drivers whose nationality is German?
|
SELECT forename , surname FROM drivers WHERE nationality = "German"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the first and last name of all the German drivers?
|
SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find the id and forenames of drivers who participated both the races with name Australian Grand Prix and the races with name Chinese Grand Prix?
|
SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?
|
SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix?
|
SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the first and last names of all drivers who participated in the Australian Grand Prix but not the Chinese Grand Prix?
|
SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find all the forenames of distinct drivers who was in position 1 as standing and won?
|
SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are all the different first names of the drivers who are in position as standing and won?
|
SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?
|
SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the first names of the different drivers who won in position 1 as driver standing and had more than 20 points?
|
SELECT count(*) , nationality FROM constructors GROUP BY nationality
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the numbers of constructors for different nationalities?
|
SELECT count(*) , nationality FROM constructors GROUP BY nationality
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. For each nationality, how many different constructors are there?
|
SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the numbers of races for each constructor id?
|
SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. For each constructor id, how many races are there?
|
SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the names of races that were held after 2017 and the circuits were in the country of Spain?
|
SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the names of the races held after 2017 in Spain?
|
SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the unique names of races that held after 2000 and the circuits were in Spain?
|
SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the names of all races held after 2000 in Spain?
|
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841)
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find the distinct driver id and the stop number of all drivers that have a shorter pit stop duration than some drivers in the race with id 841.
|
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841)
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What is the id and stop number for each driver that has a shorter pit stop than the driver in the race with id 841?
|
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841)
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?
|
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841)
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the different ids and stop durations of all the drivers whose stop lasted longer than the driver in the race with the id 841?
|
SELECT DISTINCT forename FROM drivers ORDER BY forename ASC
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. List the forenames of all distinct drivers in alphabetical order?
|
SELECT DISTINCT forename FROM drivers ORDER BY forename ASC
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. What are the first names of all the different drivers in alphabetical order?
|
SELECT DISTINCT name FROM races ORDER BY name DESC
|
Given the Table circuits having columns as circuitId has datatype number, circuitRef has datatype text, name has datatype text, location has datatype text, country has datatype text, lat has datatype number, lng has datatype number, alt has datatype number, url has datatype text which has circuitId and Given the Table races having columns as raceId has datatype number, year has datatype number, round has datatype number, circuitId has datatype number, name has datatype text, date has datatype text, time has datatype text, url has datatype text which has raceId and Given the Table drivers having columns as driverId has datatype number, driverRef has datatype text, number has datatype number, code has datatype text, forename has datatype text, surname has datatype text, dob has datatype text, nationality has datatype text, url has datatype text which has driverId and Given the Table status having columns as statusId has datatype number, status has datatype text which has statusId and Given the Table seasons having columns as year has datatype number, url has datatype text which has year and Given the Table constructors having columns as constructorId has datatype number, constructorRef has datatype text, name has datatype text, nationality has datatype text, url has datatype text which has constructorId and Given the Table constructor standings having columns as constructorStandingsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has constructorStandingsId and Given the Table results having columns as resultId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, grid has datatype number, position has datatype number, positionText has datatype text, positionOrder has datatype number, points has datatype number, laps has datatype number, time has datatype text, milliseconds has datatype number, fastestLap has datatype number, rank has datatype number, fastestLapTime has datatype text, fastestLapSpeed has datatype text, statusId has datatype number which has resultId and Given the Table driver standings having columns as driverStandingsId has datatype number, raceId has datatype number, driverId has datatype number, points has datatype number, position has datatype number, positionText has datatype text, wins has datatype number which has driverStandingsId and Given the Table constructor results having columns as constructorResultsId has datatype number, raceId has datatype number, constructorId has datatype number, points has datatype number, status has datatype number which has constructorResultsId and Given the Table qualifying having columns as qualifyId has datatype number, raceId has datatype number, driverId has datatype number, constructorId has datatype number, number has datatype number, position has datatype number, q1 has datatype text, q2 has datatype text, q3 has datatype text which has qualifyId and Given the Table pit stops having columns as raceId has datatype number, driverId has datatype number, stop has datatype number, lap has datatype number, time has datatype text, duration has datatype text, milliseconds has datatype number which has raceId and Given the Table lap times having columns as raceId has datatype number, driverId has datatype number, lap has datatype number, position has datatype number, time has datatype text, milliseconds has datatype number which has raceId. Answer the question by writing the appropriate SQL code. List the names of all distinct races in reversed lexicographic order?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.