Database: cre_Doc_Template_Mgt
# ref_template_types ( template_type_code , template_type_description )
# templates ( template_id , version_number , template_type_code , date_effective_from , date_effective_to , template_details )
# documents ( document_id , template_id , document_name , document_description , other_details )
# paragraphs ( paragraph_id , document_id , paragraph_text , other_details )
# templates.template_type_code = ref_template_types.template_type_code
# documents.template_id = templates.template_id
# paragraphs.document_id = 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 join templates on documents.template_id = templates.template_id where templates.template_type_code = 'PPT'

Question: Count the number of documents that use the PPT template type.
SQL: select count ( * ) from documents join templates on documents.template_id = templates.template_id where templates.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 documents.template_id , templates.template_type_code from documents join templates on documents.template_id = templates.template_id group by documents.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 documents.template_id , templates.template_type_code from documents join templates on documents.template_id = templates.template_id group by documents.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 templates.template_type_code from templates join documents on templates.template_id = documents.template_id where documents.document_name = 'Data base'

Question: Return the template type code of the template that is used by a document named Data base.
SQL: select templates.template_type_code from templates join documents on templates.template_id = documents.template_id where documents.document_name = 'Data base'

Question: Show all document names using templates with template type code BK.
SQL: select documents.document_name from templates join documents on templates.template_id = documents.template_id where templates.template_type_code = 'BK'

Question: What are the names of documents that use templates with the code BK?
SQL: select documents.document_name from templates join documents on templates.template_id = documents.template_id where templates.template_type_code = 'BK'

Question: Show all template type codes and the number of documents using each type.
SQL: select templates.template_type_code , count ( * ) from templates join documents on templates.template_id = documents.template_id group by templates.template_type_code

Question: What are the different template type codes, and how many documents use each type?
SQL: select templates.template_type_code , count ( * ) from templates join documents on templates.template_id = documents.template_id group by templates.template_type_code

Question: Which template type code is used by most number of documents?
SQL: select templates.template_type_code from templates join documents on templates.template_id = documents.template_id group by templates.template_type_code order by count ( * ) desc limit 1

Question: Return the code of the template type that is most commonly used in documents.
SQL: select templates.template_type_code from templates join documents on templates.template_id = documents.template_id group by templates.template_type_code order by count ( * ) desc limit 1

Question: Show all template type codes that are not used by any document.
SQL: select template_type_code from templates except select template_type_code from templates join documents on templates.template_id = documents.template_id

Question: What are the codes of template types that are not used for any document?
SQL: select template_type_code from templates except select template_type_code from templates join documents on templates.template_id = documents.template_id

Question: Show all template type codes and descriptions.
SQL: select template_type_code , template_type_description from ref_template_types

Question: What are the type codes and descriptions for all template types?
SQL: select template_type_code , template_type_description from ref_template_types

Question: What is the template type descriptions for template type code "AD".
SQL: select template_type_description from ref_template_types where template_type_code = 'AD'

Question: Return the template type description of the template type with the code AD.
SQL: select template_type_description from ref_template_types where template_type_code = 'AD'

Question: What is the template type code for template type description "Book".
SQL: select template_type_code from ref_template_types where template_type_description = 'Book'

Question: Return the type code of the template type with the description "Book".
SQL: select template_type_code from ref_template_types where template_type_description = 'Book'

Question: What are the distinct template type descriptions for the templates ever used by any document?
SQL: select distinct ref_template_types.template_type_description from ref_template_types join templates on ref_template_types.template_type_code = templates.template_type_code join documents on templates.template_id = documents.template_id

Question: Return the different descriptions for templates that have been used in a document.
SQL: select distinct ref_template_types.template_type_description from ref_template_types join templates on ref_template_types.template_type_code = templates.template_type_code join documents on templates.template_id = documents.template_id

Question: What are the template ids with template type description "Presentation".
SQL: select templates.template_id from ref_template_types join templates on ref_template_types.template_type_code = templates.template_type_code where ref_template_types.template_type_description = 'Presentation'

Question: Return the ids corresponding to templates with the description 'Presentation'.
SQL: select templates.template_id from ref_template_types join templates on ref_template_types.template_type_code = templates.template_type_code where ref_template_types.template_type_description = 'Presentation'

Question: How many paragraphs in total?
SQL: select count ( * ) from paragraphs

Question: Count the number of paragraphs.
SQL: select count ( * ) from paragraphs

Question: How many paragraphs for the document with name 'Summer Show'?
SQL: select count ( * ) from paragraphs join documents on paragraphs.document_id = documents.document_id where documents.document_name = 'Summer Show'

Question: Count the number of paragraphs in the document named 'Summer Show'.
SQL: select count ( * ) from paragraphs join documents on paragraphs.document_id = documents.document_id where documents.document_name = 'Summer Show'

Question: Show paragraph details for paragraph with text 'Korea ' .
SQL: select other_details from paragraphs where paragraph_text like 'korea'

Question: What are the details for the paragraph that includes the text 'Korea ' ?
SQL: select other_details from paragraphs where paragraph_text like 'korea'

Question: Show all paragraph ids and texts for the document with name 'Welcome to NY'.
SQL: select paragraphs.paragraph_id , paragraphs.paragraph_text from paragraphs join documents on paragraphs.document_id = documents.document_id where documents.document_name = 'Welcome to NY'

Question: What are the ids and texts of paragraphs in the document titled 'Welcome to NY'?
SQL: select paragraphs.paragraph_id , paragraphs.paragraph_text from paragraphs join documents on paragraphs.document_id = documents.document_id where documents.document_name = 'Welcome to NY'

Question: Show all paragraph texts for the document "Customer reviews".
SQL: select paragraphs.paragraph_text from paragraphs join documents on paragraphs.document_id = documents.document_id where documents.document_name = 'Customer reviews'

Question: What are the paragraph texts for the document with the name 'Customer reviews'?
SQL: select paragraphs.paragraph_text from paragraphs join documents on paragraphs.document_id = documents.document_id where documents.document_name = 'Customer reviews'

Question: Show all document ids and the number of paragraphs in each document. Order by document id.
SQL: select document_id , count ( * ) from paragraphs group by document_id order by document_id asc

Question: Return the different document ids along with the number of paragraphs corresponding to each, ordered by id.
SQL: select document_id , count ( * ) from paragraphs group by document_id order by document_id asc

Question: Show all document ids, names and the number of paragraphs in each document.
SQL: select paragraphs.document_id , documents.document_name , count ( * ) from paragraphs join documents on paragraphs.document_id = documents.document_id group by paragraphs.document_id

Question: What are the ids and names of each document, as well as the number of paragraphs in each?
SQL: select paragraphs.document_id , documents.document_name , count ( * ) from paragraphs join documents on paragraphs.document_id = documents.document_id group by paragraphs.document_id

Question: List all document ids with at least two paragraphs.
SQL: select document_id from paragraphs group by document_id having count ( * ) >= 2

Question: What are the ids of documents that have 2 or more paragraphs?
SQL: select document_id from paragraphs group by document_id having count ( * ) >= 2

Question: What is the document id and name with greatest number of paragraphs?
SQL: select paragraphs.document_id , documents.document_name from paragraphs join documents on paragraphs.document_id = documents.document_id group by paragraphs.document_id order by count ( * ) desc limit 1

Question: Return the id and name of the document with the most paragraphs.
SQL: select paragraphs.document_id , documents.document_name from paragraphs join documents on paragraphs.document_id = documents.document_id group by paragraphs.document_id order by count ( * ) desc limit 1

Question: What is the document id with least number of paragraphs?
SQL: select document_id from paragraphs group by document_id order by count ( * ) asc limit 1

Question: Return the id of the document with the fewest paragraphs.
SQL: select document_id from paragraphs group by document_id order by count ( * ) asc limit 1

Question: What is the document id with 1 to 2 paragraphs?
SQL: select document_id from paragraphs group by document_id having count ( * ) between 1 and 2

Question: Give the ids of documents that have between one and two paragraphs.
SQL: select document_id from paragraphs group by document_id having count ( * ) between 1 and 2

Question: Show the document id with paragraph text 'Brazil' and 'Ireland'.
SQL: select document_id from paragraphs where paragraph_text = 'Brazil' intersect select document_id from paragraphs where paragraph_text = 'Ireland'

Question: What are the ids of documents that contain the paragraph text 'Brazil' and 'Ireland'?
SQL: select document_id from paragraphs where paragraph_text = 'Brazil' intersect select document_id from paragraphs where paragraph_text = 'Ireland'