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 are the ids of documents with letter 's' in the name with any expense budgets.
assistant
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%'
human
What are the ids of documents which don't have expense budgets?
assistant
SELECT document_id FROM Documents EXCEPT SELECT document_id FROM Documents_with_expenses
human
What are the document ids for the budget type code 'SF'?
assistant
SELECT document_id FROM Documents_with_expenses WHERE budget_type_code = 'SF'
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
What are the dates for the documents with both 'GV' type and 'SF' type expenses?
assistant
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" ;