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
What is the document type name and the document type description and creation date for all the documents?
assistant
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
human
How many documents have expenses?
assistant
SELECT count(*) FROM Documents_with_expenses
human
Show the number of documents.
assistant
SELECT count(*) FROM Documents
human
How many documents are with document type code BK for each product id?
assistant
SELECT count(*) , project_id FROM Documents WHERE document_type_code = 'BK' GROUP BY project_id
human
What is the document type code with most number of documents?
assistant
SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
human
How many documents are there of each type?
assistant
SELECT document_type_code , COUNT( * ) FROM Documents GROUP BY document_type_code ;