[Schema (values) (types)]: | cre_Docs_and_Epenses |  Ref_Document_Types : document_type_code (text) , document_type_name (text) , document_type_description (text) | Ref_Budget_Codes : budget_type_code (text) , budget_type_description (text) | Projects : project_id (text) , project_details (text) | Documents : document_id (text) , document_type_code (text) , project_id (text) , document_date (text) , document_name (text) , document_description (text) , other_details (number) | Statements : statement_id (text) , statement_details (text) | Documents_with_Expenses : document_id (text) , budget_type_code (text) , document_details (text) | Accounts : account_id (text) , statement_id (text) , account_details (text);
[Primary Keys]: ref_document_types : document_type_code, ref_budget_codes : budget_type_code, projects : project_id, documents : document_id, statements : statement_id, documents_with_expenses : document_id, accounts : account_id
[Foreign Keys]: documents : project_id = projects : project_id | documents : document_type_code = ref_document_types : document_type_code | statements : statement_id = documents : document_id | documents_with_expenses : document_id = documents : document_id | documents_with_expenses : budget_type_code = ref_budget_codes : budget_type_code | accounts : statement_id = statements : statement_id

Question: How many accounts do we have?
SQL: SELECT count(*) FROM Accounts

Question: Count the number of accounts.
SQL: SELECT count(*) FROM Accounts

Question: Show all account ids and account details.
SQL: SELECT account_id ,  account_details FROM Accounts

Question: What are the ids and details of all accounts?
SQL: SELECT account_id ,  account_details FROM Accounts

Question: How many statements do we have?
SQL: SELECT count(*) FROM Statements

Question: Count the number of statements.
SQL: SELECT count(*) FROM Statements

Question: List all statement ids and statement details.
SQL: SELECT STATEMENT_ID ,  statement_details FROM Statements

Question: What are the ids and details of all statements?
SQL: SELECT STATEMENT_ID ,  statement_details FROM Statements

Question: Show statement id, statement detail, account detail for accounts.
SQL: SELECT T1.statement_id ,  T2.statement_details ,  T1.account_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id  =  T2.statement_id

Question: What are the statement ids, statement details, and account details, for all accounts?
SQL: SELECT T1.statement_id ,  T2.statement_details ,  T1.account_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id  =  T2.statement_id

Question: Show all statement id and the number of accounts for each statement.
SQL: SELECT STATEMENT_ID ,  count(*) FROM Accounts GROUP BY STATEMENT_ID

Question: What are the different statement ids on accounts, and the number of accounts for each?
SQL: SELECT STATEMENT_ID ,  count(*) FROM Accounts GROUP BY STATEMENT_ID

Question: Show the statement id and the statement detail for the statement with most number of accounts.
SQL: SELECT T1.statement_id ,  T2.statement_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id  =  T2.statement_id GROUP BY T1.statement_id ORDER BY count(*) DESC LIMIT 1

Question: What are the statement id and statement detail for the statement that has the most corresponding accounts?
SQL: SELECT T1.statement_id ,  T2.statement_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id  =  T2.statement_id GROUP BY T1.statement_id ORDER BY count(*) DESC LIMIT 1

Question: Show the number of documents.
SQL: SELECT count(*) FROM Documents

Question: Count the number of documents.
SQL: SELECT count(*) FROM Documents

Question: List the document type code, document name, and document description for the document with name 'Noel CV' or name 'King Book'.
SQL: SELECT document_type_code ,  document_name ,  document_description FROM Documents WHERE document_name  =  'Noel CV' OR document_name  =  'King Book'

Question: What are the type come, name, and description of the document that has either the name 'Noel CV' or 'King Book'?
SQL: SELECT document_type_code ,  document_name ,  document_description FROM Documents WHERE document_name  =  'Noel CV' OR document_name  =  'King Book'

Question: Show the ids and names of all documents.
SQL: SELECT document_id ,  document_name FROM Documents

Question: What are the ids and names for each of the documents?
SQL: SELECT document_id ,  document_name FROM Documents

Question: Find names and ids of all documents with document type code BK.
SQL: SELECT document_name ,  document_id FROM Documents WHERE document_type_code  =  "BK"

Question: What are the names and ids of documents that have the type code BK?
SQL: SELECT document_name ,  document_id FROM Documents WHERE document_type_code  =  "BK"

Question: How many documents are with document type code BK for each product id?
SQL: SELECT count(*) ,  project_id FROM Documents WHERE document_type_code  =  "BK" GROUP BY project_id

Question: Count the number of documents with the type code BK that correspond to each product id.
SQL: SELECT count(*) ,  project_id FROM Documents WHERE document_type_code  =  "BK" GROUP BY project_id

Question: Show the document name and the document date for all documents on project with details 'Graph Database project'.
SQL: 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'

Question: What are the names and dates for documents corresponding to project that has the details 'Graph Database project'?
SQL: 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'

Question: Show project ids and the number of documents in each project.
SQL: SELECT project_id ,  count(*) FROM Documents GROUP BY project_id

Question: How many documents correspond with each project id?
SQL: SELECT project_id ,  count(*) FROM Documents GROUP BY project_id

Question: What is the id of the project with least number of documents?
SQL: SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1

Question: Return the id of the project that has the fewest corresponding documents.
SQL: SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1

Question: Show the ids for projects with at least 2 documents.
SQL: SELECT project_id FROM Documents GROUP BY project_id HAVING count(*)  >=  2

Question: What are project ids of projects that have 2 or more corresponding documents?
SQL: SELECT project_id FROM Documents GROUP BY project_id HAVING count(*)  >=  2

Question: List document type codes and the number of documents in each code.
SQL: SELECT document_type_code ,  count(*) FROM Documents GROUP BY document_type_code

Question: How many documents are there of each type?
SQL: SELECT document_type_code ,  count(*) FROM Documents GROUP BY document_type_code

Question: What is the document type code with most number of documents?
SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1

Question: Return the code of the document type that is most common.
SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1

Question: Show the document type code with fewer than 3 documents.
SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*)  <  3

Question: What are the codes corresponding to document types for which there are less than 3 documents?
SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*)  <  3

Question: Show the statement detail and the corresponding document name for the statement with detail 'Private Project'.
SQL: 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'

Question: What are the details for statements with the details 'Private Project', and what are the names of the corresponding documents?
SQL: 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'

Question: Show all document type codes, document type names, document type descriptions.
SQL: SELECT document_type_code ,  document_type_name ,  document_type_description FROM Ref_document_types

Question: What are the codes, names, and descriptions of the different document types?
SQL: SELECT document_type_code ,  document_type_name ,  document_type_description FROM Ref_document_types

Question: What is the document type description for document type named Film?
SQL: SELECT document_type_description FROM Ref_document_types WHERE document_type_name  =  "Film"

Question: Return the description of the document type name 'Film'.
SQL: SELECT document_type_description FROM Ref_document_types WHERE document_type_name  =  "Film"

Question: What is the document type name and the document type description and creation date for all the documents?
SQL: 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

Question: Return the type name, type description, and date of creation for each document.
SQL: 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

Question: Show the number of projects.
SQL: SELECT count(*) FROM Projects

Question: How many projects are there?
SQL: SELECT count(*) FROM Projects

Question: List ids and details for all projects.
SQL: SELECT project_id ,  project_details FROM Projects

Question: What are the ids and details for each project?
SQL: SELECT project_id ,  project_details FROM Projects

Question: What is the project id and detail for the project with at least two documents?
SQL: 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

Question: Return the ids and details corresponding to projects for which there are more than two documents.
SQL: 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

Question: What is the project detail for the project with document "King Book"?
SQL: 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"

Question: Give the details of the project with the document name 'King Book'.
SQL: 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"

Question: How many budget types do we have?
SQL: SELECT count(*) FROM Ref_budget_codes

Question: Count the number of budget codes.
SQL: SELECT count(*) FROM Ref_budget_codes

Question: List all budget type codes and descriptions.
SQL: SELECT budget_type_code ,  budget_type_description FROM Ref_budget_codes

Question: What are the type codes and descriptions of each budget type?
SQL: SELECT budget_type_code ,  budget_type_description FROM Ref_budget_codes

Question: What is the description for the budget type with code ORG?
SQL: SELECT budget_type_description FROM Ref_budget_codes WHERE budget_type_code  =  "ORG"

Question: Return the description of the budget type that has the code ORG.
SQL: SELECT budget_type_description FROM Ref_budget_codes WHERE budget_type_code  =  "ORG"

Question: How many documents have expenses?
SQL: SELECT count(*) FROM Documents_with_expenses

Question: Count the number of documents with expenses.
SQL: SELECT count(*) FROM Documents_with_expenses

Question: What are the document ids for the budget type code 'SF'?
SQL: SELECT document_id FROM Documents_with_expenses WHERE budget_type_code  =  'SF'

Question: Give the ids of documents with expenses that have the budget code 'SF'.
SQL: SELECT document_id FROM Documents_with_expenses WHERE budget_type_code  =  'SF'

Question: Show the budget type code and description and the corresponding document id.
SQL: 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

Question: Return the budget type codes, budget type descriptions and document ids for documents with expenses.
SQL: 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

Question: Show ids for all documents with budget types described as 'Government'.
SQL: 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"

Question: Give the ids for documents that have the budget description 'Government'.
SQL: 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"

Question: Show budget type codes and the number of documents in each budget type.
SQL: SELECT budget_type_code ,  count(*) FROM Documents_with_expenses GROUP BY budget_type_code

Question: What are the different budget type codes, and how many documents are there for each?
SQL: SELECT budget_type_code ,  count(*) FROM Documents_with_expenses GROUP BY budget_type_code

Question: What is the budget type code with most number of documents.
SQL: SELECT budget_type_code FROM Documents_with_expenses GROUP BY budget_type_code ORDER BY count(*) DESC LIMIT 1

Question: Give the budget type code that is most common among documents with expenses.
SQL: SELECT budget_type_code FROM Documents_with_expenses GROUP BY budget_type_code ORDER BY count(*) DESC LIMIT 1

Question: What are the ids of documents which don't have expense budgets?
SQL: SELECT document_id FROM Documents EXCEPT SELECT document_id FROM Documents_with_expenses

Question: Return the ids of documents that do not have expenses.
SQL: SELECT document_id FROM Documents EXCEPT SELECT document_id FROM Documents_with_expenses

Question: Show ids for all documents in type CV without expense budgets.
SQL: SELECT document_id FROM Documents WHERE document_type_code  =  "CV" EXCEPT SELECT document_id FROM Documents_with_expenses

Question: What are the ids of documents with the type code CV that do not have expenses.
SQL: SELECT document_id FROM Documents WHERE document_type_code  =  "CV" EXCEPT SELECT document_id FROM Documents_with_expenses

Question: What are the ids of documents with letter 's' in the name with any expense budgets.
SQL: 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%'

Question: Give the ids of documents that have expenses and contain the letter s in their names.
SQL: 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%'

Question: How many documents do not have any expense?
SQL: SELECT count(*) FROM Documents WHERE document_id NOT IN ( SELECT document_id FROM Documents_with_expenses )

Question: Count the number of documents that do not have expenses.
SQL: SELECT count(*) FROM Documents WHERE document_id NOT IN ( SELECT document_id FROM Documents_with_expenses )

Question: What are the dates for the documents with both 'GV' type and 'SF' type expenses?
SQL: 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'

Question: Give the dates of creation for documents that have both budget type codes 'GV' and 'SF'.
SQL: 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'

Question: What are the account details with the largest value or with value having char '5' in it?
SQL: SELECT max(Account_details) FROM Accounts UNION SELECT Account_details FROM Accounts WHERE Account_details LIKE "%5%"

Question: Return the account details with the greatest value, as well as those that include the character 5.
SQL: SELECT max(Account_details) FROM Accounts UNION SELECT Account_details FROM Accounts WHERE Account_details LIKE "%5%"