Database: cre_Docs_and_Epenses

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

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

Question: List all statement ids and statement details.
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: Show all statement id and the number of accounts for each statement.
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: Show 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: Show the ids and names of all 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: 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: 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: Show project ids and the number of documents in each project.
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: Show the ids for projects with at least 2 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: 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: 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