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
Show the budget type code and description and the corresponding document id.
assistant
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
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
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 the ids and names of all documents.
assistant
SELECT document_id , document_name FROM Documents
human
Show all document type codes, document type names, document type descriptions.
assistant
SELECT document_type_code , document_type_name , document_type_description FROM Ref_document_types
human
List the document type code, document name, and document description for the document with name 'Noel CV' or name 'King Book'.
assistant
SELECT document_type_code , document_name , document_description FROM Documents WHERE document_name = "Noel CV" OR document_name = "King Book" ;