human
Schema:
Ref_Document_Types (Document_Type_Code, Document_Type_Name, Document_Type_Description)
Ref_Budget_Codes (Budget_Type_Code, Budget_Type_Description)
Projects (Project_ID, Project_Details)
Documents (Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details)
Statements (Statement_ID, Statement_Details)
Documents_with_Expenses (Document_ID, Budget_Type_Code, Document_Details)
Accounts (Account_ID, Statement_ID, Account_Details)
Please answer with SQL.
assistant
Sure, I understand.
human
How many documents have expenses?
assistant
SELECT count(*) FROM Documents_with_expenses
human
Show the document type code with fewer than 3 documents.
assistant
SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*) < 3
human
List document type codes and the number of documents in each code.
assistant
SELECT document_type_code , count(*) FROM Documents GROUP BY document_type_code
human
Show project ids and the number of documents in each project.
assistant
SELECT project_id , count(*) FROM Documents GROUP BY project_id
human
Show the ids and names of all documents.
assistant
SELECT document_id , document_name FROM Documents
human
Show the number of documents.
assistant
SELECT COUNT( * ) FROM Documents ;