CREATE TABLE Ref_Template_Types (
    Template_Type_Code TEXT PRIMARY KEY,
    Template_Type_Description TEXT
);
CREATE TABLE Templates (
    Template_ID NUMBER PRIMARY KEY,
    Version_Number NUMBER,
    Template_Type_Code TEXT,
    Date_Effective_From TIME,
    Date_Effective_To TIME,
    Template_Details TEXT,
    FOREIGN KEY ("Template_Type_Code") REFERENCES Ref_Template_Types("Template_Type_Code")
);
CREATE TABLE Documents (
    Document_ID NUMBER PRIMARY KEY,
    Template_ID NUMBER,
    Document_Name TEXT,
    Document_Description TEXT,
    Other_Details TEXT,
    FOREIGN KEY ("Template_ID") REFERENCES Templates("Template_ID")
);
CREATE TABLE Paragraphs (
    Paragraph_ID NUMBER PRIMARY KEY,
    Document_ID NUMBER,
    Paragraph_Text TEXT,
    Other_Details TEXT,
    FOREIGN KEY ("Document_ID") REFERENCES Documents("Document_ID")
);

Question: How many documents do we have?
SQL: SELECT count(*) FROM Documents

Question: Count the number of documents.
SQL: SELECT count(*) FROM Documents

Question: List document IDs, document names, and document descriptions for all documents.
SQL: SELECT document_id ,  document_name ,  document_description FROM Documents

Question: What are the ids, names, and descriptions for all documents?
SQL: SELECT document_id ,  document_name ,  document_description FROM Documents

Question: What is the document name and template id for document with description with the letter 'w' in it?
SQL: SELECT document_name ,  template_id FROM Documents WHERE Document_Description LIKE "%w%"

Question: Return the names and template ids for documents that contain the letter w in their description.
SQL: SELECT document_name ,  template_id FROM Documents WHERE Document_Description LIKE "%w%"

Question: What is the document id, template id and description for document named "Robbin CV"?
SQL: SELECT document_id ,  template_id ,  Document_Description FROM Documents WHERE document_name  =  "Robbin CV"

Question: Return the document id, template id, and description for the document with the name Robbin CV.
SQL: SELECT document_id ,  template_id ,  Document_Description FROM Documents WHERE document_name  =  "Robbin CV"

Question: How many different templates do all document use?
SQL: SELECT count(DISTINCT template_id) FROM Documents

Question: Count the number of different templates used for documents.
SQL: SELECT count(DISTINCT template_id) FROM Documents

Question: How many documents are using the template with type code 'PPT'?
SQL: SELECT count(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID  =  T2.Template_ID WHERE T2.Template_Type_Code  =  'PPT'

Question: Count the number of documents that use the PPT template type.
SQL: SELECT count(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID  =  T2.Template_ID WHERE T2.Template_Type_Code  =  'PPT'

Question: Show all template ids and number of documents using each template.
SQL: SELECT template_id ,  count(*) FROM Documents GROUP BY template_id

Question: What are all different template ids used for documents, and how many times were each of them used?
SQL: SELECT template_id ,  count(*) FROM Documents GROUP BY template_id

Question: What is the id and type code for the template used by the most documents?
SQL: SELECT T1.template_id ,  T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id  =  T2.template_id GROUP BY T1.template_id ORDER BY count(*) DESC LIMIT 1

Question: Return the id and type code of the template that is used for the greatest number of documents.
SQL: SELECT T1.template_id ,  T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id  =  T2.template_id GROUP BY T1.template_id ORDER BY count(*) DESC LIMIT 1

Question: Show ids for all templates that are used by more than one document.
SQL: SELECT template_id FROM Documents GROUP BY template_id HAVING count(*)  >  1

Question: What are the template ids of any templates used in more than a single document?
SQL: SELECT template_id FROM Documents GROUP BY template_id HAVING count(*)  >  1

Question: Show ids for all templates not used by any document.
SQL: SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents

Question: What are the ids for templates that are not used in any documents?
SQL: SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents

Question: How many templates do we have?
SQL: SELECT count(*) FROM Templates

Question: Count the number of templates.
SQL: SELECT count(*) FROM Templates

Question: Show template ids, version numbers, and template type codes for all templates.
SQL: SELECT template_id ,  version_number ,  template_type_code FROM Templates

Question: What are the ids, version numbers, and type codes for each template?
SQL: SELECT template_id ,  version_number ,  template_type_code FROM Templates

Question: Show all distinct template type codes for all templates.
SQL: SELECT DISTINCT template_type_code FROM Templates

Question: What are the different template type codes?
SQL: SELECT DISTINCT template_type_code FROM Templates

Question: What are the ids of templates with template type code PP or PPT?
SQL: SELECT template_id FROM Templates WHERE template_type_code  =  "PP" OR template_type_code  =  "PPT"

Question: Return the ids of templates that have the code PP or PPT.
SQL: SELECT template_id FROM Templates WHERE template_type_code  =  "PP" OR template_type_code  =  "PPT"

Question: How many templates have template type code CV?
SQL: SELECT count(*) FROM Templates WHERE template_type_code  =  "CV"

Question: Count the number of templates of the type CV.
SQL: SELECT count(*) FROM Templates WHERE template_type_code  =  "CV"

Question: What is the version number and template type code for the template with version number later than 5?
SQL: SELECT version_number ,  template_type_code FROM Templates WHERE version_number  >  5

Question: Return the version numbers and template type codes of templates with a version number greater than 5.
SQL: SELECT version_number ,  template_type_code FROM Templates WHERE version_number  >  5

Question: Show all template type codes and number of templates for each.
SQL: SELECT template_type_code ,  count(*) FROM Templates GROUP BY template_type_code

Question: What are the different template type codes, and how many templates correspond to each?
SQL: SELECT template_type_code ,  count(*) FROM Templates GROUP BY template_type_code

Question: Which template type code has most number of templates?
SQL: SELECT template_type_code FROM Templates GROUP BY template_type_code ORDER BY count(*) DESC LIMIT 1

Question: Return the type code of the template type that the most templates belong to.
SQL: SELECT template_type_code FROM Templates GROUP BY template_type_code ORDER BY count(*) DESC LIMIT 1

Question: Show all template type codes with less than three templates.
SQL: SELECT template_type_code FROM Templates GROUP BY template_type_code HAVING count(*)  <  3

Question: What are the codes of template types that have fewer than 3 templates?
SQL: SELECT template_type_code FROM Templates GROUP BY template_type_code HAVING count(*)  <  3

Question: What the smallest version number and its template type code?
SQL: SELECT min(Version_Number) ,  template_type_code FROM Templates

Question: Return the lowest version number, along with its corresponding template type code.
SQL: SELECT min(Version_Number) ,  template_type_code FROM Templates

Question: What is the template type code of the template used by document with the name "Data base"?
SQL: SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id  =  T2.template_id WHERE T2.document_name  =  "Data base"

Question: Return the template type code of the template that is used by a document named Data base.
SQL: SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id  =  T2.template_id WHERE T2.document_name  =  "Data base"