db_name
stringclasses
146 values
prompt
stringlengths
310
4.81k
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the names of all the documents, as well as the access counts of each, ordered alphabetically? # ### SQL: # # SELECT document_name , access_count FROM documents ORDER BY document_name # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the name of the document that has been accessed the greatest number of times, as well as the count of how many times it has been accessed? # ### SQL: # # SELECT document_name , access_count FROM documents ORDER BY access_count DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the name of the document which has been accessed the most times, as well as the number of times it has been accessed? # ### SQL: # # SELECT document_name , access_count FROM documents ORDER BY access_count DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the types of documents with more than 4 documents. # ### SQL: # # SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 4 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the codes of types of documents of which there are for or more? # ### SQL: # # SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 4 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the total access count of all documents in the most popular document type. # ### SQL: # # SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the total access count of documents that are of the most common document type? # ### SQL: # # SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the average access count of documents? # ### SQL: # # SELECT avg(access_count) FROM documents # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the average access count across all documents? # ### SQL: # # SELECT avg(access_count) FROM documents # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the structure of the document with the least number of accesses? # ### SQL: # # SELECT t2.document_structure_description FROM documents AS t1 JOIN document_structures AS t2 ON t1.document_structure_code = t2.document_structure_code GROUP BY t1.document_structure_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Return the structure description of the document that has been accessed the fewest number of times. # ### SQL: # # SELECT t2.document_structure_description FROM documents AS t1 JOIN document_structures AS t2 ON t1.document_structure_code = t2.document_structure_code GROUP BY t1.document_structure_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the type of the document named "David CV"? # ### SQL: # # SELECT document_type_code FROM documents WHERE document_name = "David CV" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Return the type code of the document named "David CV". # ### SQL: # # SELECT document_type_code FROM documents WHERE document_name = "David CV" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the list of documents that are both in the most three popular type and have the most three popular structure. # ### SQL: # # SELECT document_name FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 3 INTERSECT SELECT document_name FROM documents GROUP BY document_structure_code ORDER BY count(*) DESC LIMIT 3 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the names of documents that have both one of the three most common types and one of three most common structures? # ### SQL: # # SELECT document_name FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 3 INTERSECT SELECT document_name FROM documents GROUP BY document_structure_code ORDER BY count(*) DESC LIMIT 3 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What document types do have more than 10000 total access number. # ### SQL: # # SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count) > 10000 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Return the codes of the document types that do not have a total access count of over 10000. # ### SQL: # # SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count) > 10000 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are all the section titles of the document named "David CV"? # ### SQL: # # SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code WHERE t1.document_name = "David CV" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Give the section titles of the document with the name "David CV". # ### SQL: # # SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code WHERE t1.document_name = "David CV" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find all the name of documents without any sections. # ### SQL: # # SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections) # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the names of documents that do not have any sections? # ### SQL: # # SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections) # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # List all the username and passwords of users with the most popular role. # ### SQL: # # SELECT user_name , password FROM users GROUP BY role_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the usernames and passwords of users that have the most common role? # ### SQL: # # SELECT user_name , password FROM users GROUP BY role_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the average access counts of documents with functional area "Acknowledgement". # ### SQL: # # SELECT avg(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = "Acknowledgement" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the average access counts of documents that have the functional area description "Acknowledgement"? # ### SQL: # # SELECT avg(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = "Acknowledgement" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find names of the document without any images. # ### SQL: # # SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code JOIN document_sections_images AS t3 ON t2.section_id = t3.section_id # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the names of documents that do not have any images? # ### SQL: # # SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code JOIN document_sections_images AS t3 ON t2.section_id = t3.section_id # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the name of the document with the most number of sections? # ### SQL: # # SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Return the name of the document that has the most sections. # ### SQL: # # SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # List all the document names which contains "CV". # ### SQL: # # SELECT document_name FROM documents WHERE document_name LIKE "%CV%" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the names of documents that contain the substring "CV"? # ### SQL: # # SELECT document_name FROM documents WHERE document_name LIKE "%CV%" # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # How many users are logged in? # ### SQL: # # SELECT count(*) FROM users WHERE user_login = 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Count the number of users that are logged in. # ### SQL: # # SELECT count(*) FROM users WHERE user_login = 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the description of the most popular role among the users that have logged in. # ### SQL: # # SELECT role_description FROM ROLES WHERE role_code = (SELECT role_code FROM users WHERE user_login = 1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1) # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the description of the most popular role among users that have logged in? # ### SQL: # # SELECT role_description FROM ROLES WHERE role_code = (SELECT role_code FROM users WHERE user_login = 1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1) # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the average access count of documents with the least popular structure. # ### SQL: # # SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What is the average access count of documents that have the least common structure? # ### SQL: # # SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # List all the image name and URLs in the order of their names. # ### SQL: # # SELECT image_name , image_url FROM images ORDER BY image_name # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the names and urls of images, sorted alphabetically? # ### SQL: # # SELECT image_name , image_url FROM images ORDER BY image_name # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Find the number of users in each role. # ### SQL: # # SELECT count(*) , role_code FROM users GROUP BY role_code # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What are the different role codes for users, and how many users have each? # ### SQL: # # SELECT count(*) , role_code FROM users GROUP BY role_code # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # What document types have more than 2 corresponding documents? # ### SQL: # # SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 2 # ### End.
document_management
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Roles ( role_code, role_description ) # Users ( user_id, role_code, user_name, user_login, password ) # Document_Structures ( document_structure_code, parent_document_structure_code, document_structure_description ) # Functional_Areas ( functional_area_code, parent_functional_area_code, functional_area_description ) # Images ( image_id, image_alt_text, image_name, image_url ) # Documents ( document_code, document_structure_code, document_type_code, access_count, document_name ) # Document_Functional_Areas ( document_code, functional_area_code ) # Document_Sections ( section_id, document_code, section_sequence, section_code, section_title ) # Document_Sections_Images ( section_id, image_id ) # # Users.role_code can be joined with Roles.role_code # Documents.document_structure_code can be joined with Document_Structures.document_structure_code # Document_Functional_Areas.functional_area_code can be joined with Functional_Areas.functional_area_code # Document_Functional_Areas.document_code can be joined with Documents.document_code # Document_Sections.document_code can be joined with Documents.document_code # Document_Sections_Images.image_id can be joined with Images.image_id # Document_Sections_Images.section_id can be joined with Document_Sections.section_id # ### Question: # # Give the codes of document types that have more than 2 corresponding documents. # ### SQL: # # SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 2 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # How many companies are there? # ### SQL: # # SELECT count(*) FROM Companies # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Count the number of companies. # ### SQL: # # SELECT count(*) FROM Companies # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # List the names of companies in descending order of market value. # ### SQL: # # SELECT name FROM Companies ORDER BY Market_Value_billion DESC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Sort the company names in descending order of the company's market value. # ### SQL: # # SELECT name FROM Companies ORDER BY Market_Value_billion DESC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # What are the names of companies whose headquarters are not "USA"? # ### SQL: # # SELECT name FROM Companies WHERE Headquarters != 'USA' # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Find the names of the companies whose headquarters are not located in "USA". # ### SQL: # # SELECT name FROM Companies WHERE Headquarters != 'USA' # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # What are the name and assets of each company, sorted in ascending order of company name? # ### SQL: # # SELECT name , Assets_billion FROM Companies ORDER BY name ASC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # List the name and assets of each company in ascending order of company name. # ### SQL: # # SELECT name , Assets_billion FROM Companies ORDER BY name ASC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # What are the average profits of companies? # ### SQL: # # SELECT avg(Profits_billion) FROM Companies # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Compute the average profits companies make. # ### SQL: # # SELECT avg(Profits_billion) FROM Companies # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # What are the maximum and minimum sales of the companies whose industries are not "Banking". # ### SQL: # # SELECT max(Sales_billion) , min(Sales_billion) FROM Companies WHERE Industry != "Banking" # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Find the maximum and minimum sales of the companies that are not in the "Banking" industry. # ### SQL: # # SELECT max(Sales_billion) , min(Sales_billion) FROM Companies WHERE Industry != "Banking" # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # How many different industries are the companies in? # ### SQL: # # SELECT count(DISTINCT Industry) FROM Companies # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Count the number of distinct company industries. # ### SQL: # # SELECT count(DISTINCT Industry) FROM Companies # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # List the names of buildings in descending order of building height. # ### SQL: # # SELECT name FROM buildings ORDER BY Height DESC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # What are the names of buildings sorted in descending order of building height? # ### SQL: # # SELECT name FROM buildings ORDER BY Height DESC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Find the stories of the building with the largest height. # ### SQL: # # SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # What is the stories of highest building? # ### SQL: # # SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # List the name of a building along with the name of a company whose office is in the building. # ### SQL: # # SELECT T3.name , T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # For each company, return the company name and the name of the building its office is located in. # ### SQL: # # SELECT T3.name , T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Show the names of the buildings that have more than one company offices. # ### SQL: # # SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Which buildings have more than one company offices? Give me the building names. # ### SQL: # # SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Show the name of the building that has the most company offices. # ### SQL: # # SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Which building has the largest number of company offices? Give me the building name. # ### SQL: # # SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Please show the names of the buildings whose status is "on-hold", in ascending order of stories. # ### SQL: # # SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories ASC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Find the names of the buildings in "on-hold" status, and sort them in ascending order of building stories. # ### SQL: # # SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories ASC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Please show each industry and the corresponding number of companies in that industry. # ### SQL: # # SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Whah are the name of each industry and the number of companies in that industry? # ### SQL: # # SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Please show the industries of companies in descending order of the number of companies. # ### SQL: # # SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Sort all the industries in descending order of the count of companies in each industry # ### SQL: # # SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # List the industry shared by the most companies. # ### SQL: # # SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Which industry has the most companies? # ### SQL: # # SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # List the names of buildings that have no company office. # ### SQL: # # SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations) # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Which buildings do not have any company office? Give me the building names. # ### SQL: # # SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations) # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China". # ### SQL: # # SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Which industries have both companies with headquarter in "USA" and companies with headquarter in "China"? # ### SQL: # # SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Find the number of companies whose industry is "Banking" or "Conglomerate", # ### SQL: # # SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # How many companies are in either "Banking" industry or "Conglomerate" industry? # ### SQL: # # SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Show the headquarters shared by more than two companies. # ### SQL: # # SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 # ### End.
company_office
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # buildings ( id, name, City, Height, Stories, Status ) # Companies ( id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion ) # Office_locations ( building_id, company_id, move_in_year ) # # Office_locations.company_id can be joined with Companies.id # Office_locations.building_id can be joined with buildings.id # ### Question: # # Which headquarter locations are used by more than 2 companies? # ### SQL: # # SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # How many products are there? # ### SQL: # # SELECT count(*) FROM Products # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # List the name of products in ascending order of price. # ### SQL: # # SELECT Product_Name FROM Products ORDER BY Product_Price ASC # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # What are the names and type codes of products? # ### SQL: # # SELECT Product_Name , Product_Type_Code FROM Products # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the prices of the products named "Dining" or "Trading Policy". # ### SQL: # # SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy" # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # What is the average price for products? # ### SQL: # # SELECT avg(Product_Price) FROM Products # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # What is the name of the product with the highest price? # ### SQL: # # SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1 # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show different type codes of products and the number of products with each type code. # ### SQL: # # SELECT Product_Type_Code , COUNT(*) FROM Products GROUP BY Product_Type_Code # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the most common type code across products. # ### SQL: # # SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the product type codes that have at least two products. # ### SQL: # # SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2 # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000. # ### SQL: # # SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000 # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the names of products and the number of events they are in. # ### SQL: # # SELECT T1.Product_Name , COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the names of products and the number of events they are in, sorted by the number of events in descending order. # ### SQL: # # SELECT T1.Product_Name , COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name ORDER BY COUNT(*) DESC # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the names of products that are in at least two events. # ### SQL: # # SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # Show the names of products that are in at least two events in ascending alphabetical order of product name. # ### SQL: # # SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 ORDER BY T1.Product_Name # ### End.
solvency_ii
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( Address_ID, address_details ) # Locations ( Location_ID, Other_Details ) # Products ( Product_ID, Product_Type_Code, Product_Name, Product_Price ) # Parties ( Party_ID, Party_Details ) # Assets ( Asset_ID, Other_Details ) # Channels ( Channel_ID, Other_Details ) # Finances ( Finance_ID, Other_Details ) # Events ( Event_ID, Address_ID, Channel_ID, Event_Type_Code, Finance_ID, Location_ID ) # Products_in_Events ( Product_in_Event_ID, Event_ID, Product_ID ) # Parties_in_Events ( Party_ID, Event_ID, Role_Code ) # Agreements ( Document_ID, Event_ID ) # Assets_in_Events ( Asset_ID, Event_ID ) # # Events.Finance_ID can be joined with Finances.Finance_ID # Events.Address_ID can be joined with Addresses.Address_ID # Events.Location_ID can be joined with Locations.Location_ID # Products_in_Events.Product_ID can be joined with Products.Product_ID # Products_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Event_ID can be joined with Events.Event_ID # Parties_in_Events.Party_ID can be joined with Parties.Party_ID # Agreements.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # Assets_in_Events.Event_ID can be joined with Events.Event_ID # ### Question: # # List the names of products that are not in any event. # ### SQL: # # SELECT Product_Name FROM Products WHERE Product_ID NOT IN (SELECT Product_ID FROM Products_in_Events) # ### End.
entertainment_awards
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # festival_detail ( Festival_ID, Festival_Name, Chair_Name, Location, Year, Num_of_Audience ) # artwork ( Artwork_ID, Type, Name ) # nomination ( Artwork_ID, Festival_ID, Result ) # # nomination.Festival_ID can be joined with festival_detail.Festival_ID # nomination.Artwork_ID can be joined with artwork.Artwork_ID # ### Question: # # How many artworks are there? # ### SQL: # # SELECT count(*) FROM artwork # ### End.
entertainment_awards
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # festival_detail ( Festival_ID, Festival_Name, Chair_Name, Location, Year, Num_of_Audience ) # artwork ( Artwork_ID, Type, Name ) # nomination ( Artwork_ID, Festival_ID, Result ) # # nomination.Festival_ID can be joined with festival_detail.Festival_ID # nomination.Artwork_ID can be joined with artwork.Artwork_ID # ### Question: # # List the name of artworks in ascending alphabetical order. # ### SQL: # # SELECT Name FROM artwork ORDER BY Name ASC # ### End.