human
Schema:
Ref_Document_Types (document_type_code, document_type_description)
Roles (role_code, role_description)
Addresses (address_id, address_details)
Ref_Document_Status (document_status_code, document_status_description)
Ref_Shipping_Agents (shipping_agent_code, shipping_agent_name, shipping_agent_description)
Documents (document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details)
Employees (employee_id, role_code, employee_name, other_details)
Document_Drafts (document_id, draft_number, draft_details)
Draft_Copies (document_id, draft_number, copy_number)
Circulation_History (document_id, draft_number, copy_number, employee_id)
Documents_Mailed (document_id, mailed_to_address_id, mailing_date)
Please answer with SQL.
assistant
Sure, I understand.
human
What document type codes do we have?
assistant
SELECT document_type_code FROM Ref_Document_Types;
human
What is the document status description of the document with id 1?
assistant
SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;
human
List the document ids for any documents with the status code done and the type code paper.
assistant
SELECT document_id FROM Documents WHERE document_status_code = 'done' AND document_type_code = 'Paper';
human
What is the description of document status code 'working'?
assistant
SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = 'working';
human
What document status codes do we have?
assistant
SELECT document_status_code FROM Ref_Document_Status;
human
How many documents have the status code done?
assistant
SELECT COUNT( * ) FROM Documents WHERE document_status_code = "done" ;