Database: cre_Doc_Control_Systems

Question: What document status codes do we have?
SQL: SELECT document_status_code FROM Ref_Document_Status;

Question: What is the description of document status code 'working'?
SQL: SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working";

Question: What document type codes do we have?
SQL: SELECT document_type_code FROM Ref_Document_Types;

Question: What is the description of document type 'Paper'?
SQL: SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";

Question: What are the shipping agent names?
SQL: SELECT shipping_agent_name FROM Ref_Shipping_Agents;

Question: What is the shipping agent code of shipping agent UPS?
SQL: SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";

Question: What are all role codes?
SQL: SELECT role_code FROM ROLES;

Question: What is the description of role code ED?
SQL: SELECT role_description FROM ROLES WHERE role_code = "ED";

Question: How many employees do we have?
SQL: SELECT count(*) FROM Employees;

Question: What is the role of the employee named Koby?
SQL: SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";

Question: List all document ids and receipt dates of documents.
SQL: SELECT document_id ,  receipt_date FROM Documents;

Question: How many employees does each role have? List role description, id and number of employees.
SQL: SELECT T1.role_description ,  T2.role_code ,  count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code;

Question: List roles that have more than one employee. List the role description and number of employees.
SQL: SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id)  >  1;

Question: What is the document status description of the document with id 1?
SQL: 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;

Question: How many documents have the status code done?
SQL: SELECT count(*) FROM Documents WHERE document_status_code = "done";

Question: List the document type code for the document with the id 2.
SQL: SELECT document_type_code FROM Documents WHERE document_id = 2;

Question: List the document ids for any documents with the status code done and the type code paper.
SQL: SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";

Question: What is the name of the shipping agent of the document with id 2?
SQL: SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2;