DDL_schema
stringlengths
263
8.16k
query
stringlengths
18
577
question
stringlengths
3
224
db_id
stringlengths
3
31
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Documents
Count the number of documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code , document_name , document_description FROM Documents WHERE document_name = 'Noel CV' OR document_name = 'King Book'
List the document type code, document name, and document description for the document with name 'Noel CV' or name 'King Book'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code , document_name , document_description FROM Documents WHERE document_name = 'Noel CV' OR document_name = 'King Book'
What are the type come, name, and description of the document that has either the name 'Noel CV' or 'King Book'?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id , document_name FROM Documents
Show the ids and names of all documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id , document_name FROM Documents
What are the ids and names for each of the documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_name , document_id FROM Documents WHERE document_type_code = "BK"
Find names and ids of all documents with document type code BK.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_name , document_id FROM Documents WHERE document_type_code = "BK"
What are the names and ids of documents that have the type code BK?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) , project_id FROM Documents WHERE document_type_code = "BK" GROUP BY project_id
How many documents are with document type code BK for each product id?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) , project_id FROM Documents WHERE document_type_code = "BK" GROUP BY project_id
Count the number of documents with the type code BK that correspond to each product id.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_name , document_date FROM Documents AS T1 JOIN projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'Graph Database project'
Show the document name and the document date for all documents on project with details 'Graph Database project'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_name , document_date FROM Documents AS T1 JOIN projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'Graph Database project'
What are the names and dates for documents corresponding to project that has the details 'Graph Database project'?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id , count(*) FROM Documents GROUP BY project_id
Show project ids and the number of documents in each project.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id , count(*) FROM Documents GROUP BY project_id
How many documents correspond with each project id?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1
What is the id of the project with least number of documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1
Return the id of the project that has the fewest corresponding documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id FROM Documents GROUP BY project_id HAVING count(*) >= 2
Show the ids for projects with at least 2 documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id FROM Documents GROUP BY project_id HAVING count(*) >= 2
What are project ids of projects that have 2 or more corresponding documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code , count(*) FROM Documents GROUP BY document_type_code
List document type codes and the number of documents in each code.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code , count(*) FROM Documents GROUP BY document_type_code
How many documents are there of each type?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
What is the document type code with most number of documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
Return the code of the document type that is most common.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*) < 3
Show the document type code with fewer than 3 documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*) < 3
What are the codes corresponding to document types for which there are less than 3 documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.statement_details , T2.document_name FROM Statements AS T1 JOIN Documents AS T2 ON T1.statement_id = T2.document_id WHERE T1.statement_details = 'Private Project'
Show the statement detail and the corresponding document name for the statement with detail 'Private Project'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.statement_details , T2.document_name FROM Statements AS T1 JOIN Documents AS T2 ON T1.statement_id = T2.document_id WHERE T1.statement_details = 'Private Project'
What are the details for statements with the details 'Private Project', and what are the names of the corresponding documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code , document_type_name , document_type_description FROM Ref_document_types
Show all document type codes, document type names, document type descriptions.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_code , document_type_name , document_type_description FROM Ref_document_types
What are the codes, names, and descriptions of the different document types?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_description FROM Ref_document_types WHERE document_type_name = "Film"
What is the document type description for document type named Film?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_type_description FROM Ref_document_types WHERE document_type_name = "Film"
Return the description of the document type name 'Film'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_type_name , T1.document_type_description , T2.Document_date FROM Ref_document_types AS T1 JOIN Documents AS T2 ON T1.document_type_code = T2.document_type_code
What is the document type name and the document type description and creation date for all the documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_type_name , T1.document_type_description , T2.Document_date FROM Ref_document_types AS T1 JOIN Documents AS T2 ON T1.document_type_code = T2.document_type_code
Return the type name, type description, and date of creation for each document.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Projects
Show the number of projects.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Projects
How many projects are there?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id , project_details FROM Projects
List ids and details for all projects.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT project_id , project_details FROM Projects
What are the ids and details for each project?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.project_id , T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id HAVING count(*) > 2
What is the project id and detail for the project with at least two documents?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.project_id , T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id HAVING count(*) > 2
Return the ids and details corresponding to projects for which there are more than two documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id WHERE T2.document_name = "King Book"
What is the project detail for the project with document "King Book"?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id WHERE T2.document_name = "King Book"
Give the details of the project with the document name 'King Book'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Ref_budget_codes
How many budget types do we have?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Ref_budget_codes
Count the number of budget codes.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_code , budget_type_description FROM Ref_budget_codes
List all budget type codes and descriptions.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_code , budget_type_description FROM Ref_budget_codes
What are the type codes and descriptions of each budget type?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_description FROM Ref_budget_codes WHERE budget_type_code = "ORG"
What is the description for the budget type with code ORG?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_description FROM Ref_budget_codes WHERE budget_type_code = "ORG"
Return the description of the budget type that has the code ORG.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Documents_with_expenses
How many documents have expenses?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Documents_with_expenses
Count the number of documents with expenses.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id FROM Documents_with_expenses WHERE budget_type_code = 'SF'
What are the document ids for the budget type code 'SF'?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id FROM Documents_with_expenses WHERE budget_type_code = 'SF'
Give the ids of documents with expenses that have the budget code 'SF'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T2.budget_type_code , T2.budget_type_description , T1.document_id FROM Documents_with_expenses AS T1 JOIN Ref_budget_codes AS T2 ON T1.budget_type_code = T2.budget_type_code
Show the budget type code and description and the corresponding document id.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T2.budget_type_code , T2.budget_type_description , T1.document_id FROM Documents_with_expenses AS T1 JOIN Ref_budget_codes AS T2 ON T1.budget_type_code = T2.budget_type_code
Return the budget type codes, budget type descriptions and document ids for documents with expenses.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_id FROM Documents_with_expenses AS T1 JOIN Ref_Budget_Codes AS T2 ON T1.Budget_Type_code = T2.Budget_Type_code WHERE T2.budget_type_Description = "Government"
Show ids for all documents with budget types described as 'Government'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_id FROM Documents_with_expenses AS T1 JOIN Ref_Budget_Codes AS T2 ON T1.Budget_Type_code = T2.Budget_Type_code WHERE T2.budget_type_Description = "Government"
Give the ids for documents that have the budget description 'Government'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_code , count(*) FROM Documents_with_expenses GROUP BY budget_type_code
Show budget type codes and the number of documents in each budget type.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_code , count(*) FROM Documents_with_expenses GROUP BY budget_type_code
What are the different budget type codes, and how many documents are there for each?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_code FROM Documents_with_expenses GROUP BY budget_type_code ORDER BY count(*) DESC LIMIT 1
What is the budget type code with most number of documents.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT budget_type_code FROM Documents_with_expenses GROUP BY budget_type_code ORDER BY count(*) DESC LIMIT 1
Give the budget type code that is most common among documents with expenses.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id FROM Documents EXCEPT SELECT document_id FROM Documents_with_expenses
What are the ids of documents which don't have expense budgets?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id FROM Documents EXCEPT SELECT document_id FROM Documents_with_expenses
Return the ids of documents that do not have expenses.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id FROM Documents WHERE document_type_code = "CV" EXCEPT SELECT document_id FROM Documents_with_expenses
Show ids for all documents in type CV without expense budgets.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT document_id FROM Documents WHERE document_type_code = "CV" EXCEPT SELECT document_id FROM Documents_with_expenses
What are the ids of documents with the type code CV that do not have expenses.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_id FROM Documents AS T1 JOIN Documents_with_expenses AS T2 ON T1.document_id = T2.document_id WHERE T1.document_name LIKE '%s%'
What are the ids of documents with letter 's' in the name with any expense budgets.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_id FROM Documents AS T1 JOIN Documents_with_expenses AS T2 ON T1.document_id = T2.document_id WHERE T1.document_name LIKE '%s%'
Give the ids of documents that have expenses and contain the letter s in their names.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Documents WHERE document_id NOT IN ( SELECT document_id FROM Documents_with_expenses )
How many documents do not have any expense?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT count(*) FROM Documents WHERE document_id NOT IN ( SELECT document_id FROM Documents_with_expenses )
Count the number of documents that do not have expenses.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_date FROM Documents AS T1 JOIN Documents_with_Expenses AS T2 ON T1.document_id = T2.document_id WHERE T2.budget_type_code = 'GV' INTERSECT SELECT T1.document_date FROM Documents AS T1 JOIN Documents_with_Expenses AS T2 ON T1.document_id = T2.document_id WHERE T2.budget_type_code = 'SF'
What are the dates for the documents with both 'GV' type and 'SF' type expenses?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT T1.document_date FROM Documents AS T1 JOIN Documents_with_Expenses AS T2 ON T1.document_id = T2.document_id WHERE T2.budget_type_code = 'GV' INTERSECT SELECT T1.document_date FROM Documents AS T1 JOIN Documents_with_Expenses AS T2 ON T1.document_id = T2.document_id WHERE T2.budget_type_code = 'SF'
Give the dates of creation for documents that have both budget type codes 'GV' and 'SF'.
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT max(Account_details) FROM Accounts UNION SELECT Account_details FROM Accounts WHERE Account_details LIKE "%5%"
What are the account details with the largest value or with value having char '5' in it?
cre_Docs_and_Epenses
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) NOT NULL, Document_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Document_Type_Code) ) CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) )
SELECT max(Account_details) FROM Accounts UNION SELECT Account_details FROM Accounts WHERE Account_details LIKE "%5%"
Return the account details with the greatest value, as well as those that include the character 5.
cre_Docs_and_Epenses
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) FROM scientists
Find the total number of scientists.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) FROM scientists
How many scientists are there?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT sum(hours) FROM projects
Find the total hours of all projects.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT sum(hours) FROM projects
What is the total number of hours for all projects?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(DISTINCT scientist) FROM assignedto
How many different scientists are assigned to any project?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(DISTINCT scientist) FROM assignedto
Count the number of different scientists assigned to any project.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(DISTINCT name) FROM projects
Find the number of distinct projects.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(DISTINCT name) FROM projects
How many different projects are there?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT avg(hours) FROM projects
Find the average hours of all projects.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT avg(hours) FROM projects
What is the average hours across all projects?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM projects ORDER BY hours DESC LIMIT 1
Find the name of project that continues for the longest time.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM projects ORDER BY hours DESC LIMIT 1
What is the name of the project with the most hours?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM projects WHERE hours > (SELECT avg(hours) FROM projects)
List the name of all projects that are operated longer than the average working hours of all projects.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM projects WHERE hours > (SELECT avg(hours) FROM projects)
What are the names of projects that have taken longer than the average number of hours for all projects?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT T1.name , T1.hours FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T2.project ORDER BY count(*) DESC LIMIT 1
Find the name and hours of project that has the most number of scientists.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT T1.name , T1.hours FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T2.project ORDER BY count(*) DESC LIMIT 1
What is the name and hours for the project which has the most scientists assigned to it?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT T2.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name LIKE '%Smith%'
Find the name of the project for which a scientist whose name contains ‘Smith’ is assigned to.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT T2.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name LIKE '%Smith%'
What is the name of the project that has a scientist assigned to it whose name contains 'Smith'?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT sum(T2.hours) FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name = 'Michael Rogers' OR T3.name = 'Carol Smith'
Find the total hours of the projects that scientists named Michael Rogers or Carol Smith are assigned to.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT sum(T2.hours) FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name = 'Michael Rogers' OR T3.name = 'Carol Smith'
What is the sum of hours for projects that scientists with the name Michael Rogers or Carol Smith are assigned to?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM projects WHERE hours BETWEEN 100 AND 300
Find the name of projects that require between 100 and 300 hours of work.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM projects WHERE hours BETWEEN 100 AND 300
What are the names of projects that require between 100 and 300 hours?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.name = 'Matter of Time' INTERSECT SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.name = 'A Puzzling Parallax'
Find the name of the scientist who worked on both a project named 'Matter of Time' and a project named 'A Puzzling Parallax'.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.name = 'Matter of Time' INTERSECT SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.name = 'A Puzzling Parallax'
What are the names of any scientists who worked on projects named 'Matter of Time' and 'A Puzzling Pattern'?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM scientists ORDER BY name
List the names of all scientists sorted in alphabetical order.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT name FROM scientists ORDER BY name
What are the names of all the scientists in alphabetical order?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) , T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T1.name
Find the number of scientists involved for each project name.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) , T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T1.name
What are the naems of all the projects, and how many scientists were assigned to each of them?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) , T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project WHERE T1.hours > 300 GROUP BY T1.name
Find the number of scientists involved for the projects that require more than 300 hours.
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) , T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project WHERE T1.hours > 300 GROUP BY T1.name
What are the names of projects that require more than 300 hours, and how many scientists are assigned to each?
scientist_1
CREATE TABLE Scientists ( SSN int, Name Char(30) not null, Primary Key (SSN) ) CREATE TABLE Projects ( Code Char(4), Name Char(50) not null, Hours int, Primary Key (Code) ) CREATE TABLE AssignedTo ( Scientist int not null, Project char(4) not null, Primary Key (Scientist, Project), Foreign Key (Scientist) references Scientists (SSN), Foreign Key (Project) references Projects (Code) )
SELECT count(*) , T1.name FROM scientists AS T1 JOIN assignedto AS T2 ON T1.ssn = T2.scientist GROUP BY T1.name
Find the number of projects which each scientist is working on and scientist's name.
scientist_1