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 project ids and the number of documents in each project.
assistant
SELECT project_id , count(*) FROM Documents GROUP BY project_id
human
What is the id of the project with least number of documents?
assistant
SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1
human
List ids and details for all projects.
assistant
SELECT project_id , project_details FROM Projects
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
What is the project id and detail for the project with at least two documents?
assistant
SELECT T1.project_id , T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id HAVING count(*) > 2
human
What are the names and dates for documents corresponding to project that has the details 'Graph Database project'?
assistant
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" ;