db_id
stringlengths
3
31
query
stringlengths
18
577
question
stringlengths
3
224
schema
stringlengths
177
6.14k
primary_keys
stringlengths
16
545
foreign_keys
stringlengths
16
1.48k
document_management
SELECT document_name , access_count FROM documents ORDER BY document_name
What are the names of all the documents, as well as the access counts of each, ordered alphabetically?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_name , access_count FROM documents ORDER BY access_count DESC LIMIT 1
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?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_name , access_count FROM documents ORDER BY access_count DESC LIMIT 1
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?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 4
Find the types of documents with more than 4 documents.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 4
What are the codes of types of documents of which there are for or more?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
Find the total access count of all documents in the most popular document type.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
What is the total access count of documents that are of the most common document type?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT avg(access_count) FROM documents
What is the average access count of documents?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT avg(access_count) FROM documents
Find the average access count across all documents?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
What is the structure of the document with the least number of accesses?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
Return the structure description of the document that has been accessed the fewest number of times.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents WHERE document_name = "David CV"
What is the type of the document named "David CV"?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents WHERE document_name = "David CV"
Return the type code of the document named "David CV".
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
Find the list of documents that are both in the most three popular type and have the most three popular structure.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
What are the names of documents that have both one of the three most common types and one of three most common structures?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count) > 10000
What document types do have more than 10000 total access number.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count) > 10000
Return the codes of the document types that do not have a total access count of over 10000.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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"
What are all the section titles of the document named "David CV"?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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"
Give the section titles of the document with the name "David CV".
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections)
Find all the name of documents without any sections.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections)
What are the names of documents that do not have any sections?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT user_name , password FROM users GROUP BY role_code ORDER BY count(*) DESC LIMIT 1
List all the username and passwords of users with the most popular role.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT user_name , password FROM users GROUP BY role_code ORDER BY count(*) DESC LIMIT 1
What are the usernames and passwords of users that have the most common role?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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"
Find the average access counts of documents with functional area "Acknowledgement".
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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"
What are the average access counts of documents that have the functional area description "Acknowledgement"?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
Find names of the document without any images.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
What are the names of documents that do not have any images?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
What is the name of the document with the most number of sections?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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
Return the name of the document that has the most sections.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_name FROM documents WHERE document_name LIKE "%CV%"
List all the document names which contains "CV".
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_name FROM documents WHERE document_name LIKE "%CV%"
What are the names of documents that contain the substring "CV"?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT count(*) FROM users WHERE user_login = 1
How many users are logged in?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT count(*) FROM users WHERE user_login = 1
Count the number of users that are logged in.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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)
Find the description of the most popular role among the users that have logged in.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
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)
What is the description of the most popular role among users that have logged in?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1
Find the average access count of documents with the least popular structure.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1
What is the average access count of documents that have the least common structure?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT image_name , image_url FROM images ORDER BY image_name
List all the image name and URLs in the order of their names.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT image_name , image_url FROM images ORDER BY image_name
What are the names and urls of images, sorted alphabetically?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT count(*) , role_code FROM users GROUP BY role_code
Find the number of users in each role.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT count(*) , role_code FROM users GROUP BY role_code
What are the different role codes for users, and how many users have each?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 2
What document types have more than 2 corresponding documents?
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 2
Give the codes of document types that have more than 2 corresponding documents.
[Schema (values) (types)]: | document_management | Roles : role_code (text) , role_description (text) | Users : user_id (text) , role_code (text) , user_name (text) , user_login (number) , password (text) | Document_Structures : document_structure_code (text) , parent_document_structure_code (text) , document_structure_description (text) | Functional_Areas : functional_area_code (text) , parent_functional_area_code (text) , functional_area_description (text) | Images : image_id (text) , image_alt_text (text) , image_name (text) , image_url (number) | Documents : document_code (text) , document_structure_code (text) , document_type_code (text) , access_count (number) , document_name (text) | Document_Functional_Areas : document_code (text) , functional_area_code (text) | Document_Sections : section_id (text) , document_code (text) , section_sequence (text) , section_code (number) , section_title (text) | Document_Sections_Images : section_id (text) , image_id (text);
[Primary Keys]: roles : role_code, users : user_id, document_structures : document_structure_code, functional_areas : functional_area_code, images : image_id, documents : document_code, document_functional_areas : section_id, document_sections : section_id
[Foreign Keys]: users : role_code = roles : role_code | documents : document_structure_code = document_structures : document_structure_code | document_functional_areas : functional_area_code = functional_areas : functional_area_code | document_functional_areas : document_code = documents : document_code | document_sections : document_code = documents : document_code | document_sections_images : image_id = images : image_id | document_sections_images : section_id = document_sections : section_id
company_office
SELECT count(*) FROM Companies
How many companies are there?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT count(*) FROM Companies
Count the number of companies.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM Companies ORDER BY Market_Value_billion DESC
List the names of companies in descending order of market value.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM Companies ORDER BY Market_Value_billion DESC
Sort the company names in descending order of the company's market value.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM Companies WHERE Headquarters != 'USA'
What are the names of companies whose headquarters are not "USA"?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM Companies WHERE Headquarters != 'USA'
Find the names of the companies whose headquarters are not located in "USA".
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name , Assets_billion FROM Companies ORDER BY name ASC
What are the name and assets of each company, sorted in ascending order of company name?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name , Assets_billion FROM Companies ORDER BY name ASC
List the name and assets of each company in ascending order of company name.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT avg(Profits_billion) FROM Companies
What are the average profits of companies?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT avg(Profits_billion) FROM Companies
Compute the average profits companies make.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT max(Sales_billion) , min(Sales_billion) FROM Companies WHERE Industry != "Banking"
What are the maximum and minimum sales of the companies whose industries are not "Banking".
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT max(Sales_billion) , min(Sales_billion) FROM Companies WHERE Industry != "Banking"
Find the maximum and minimum sales of the companies that are not in the "Banking" industry.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT count(DISTINCT Industry) FROM Companies
How many different industries are the companies in?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT count(DISTINCT Industry) FROM Companies
Count the number of distinct company industries.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM buildings ORDER BY Height DESC
List the names of buildings in descending order of building height.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM buildings ORDER BY Height DESC
What are the names of buildings sorted in descending order of building height?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1
Find the stories of the building with the largest height.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1
What is the stories of highest building?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
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
List the name of a building along with the name of a company whose office is in the building.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
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
For each company, return the company name and the name of the building its office is located in.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
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
Show the names of the buildings that have more than one company offices.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
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
Which buildings have more than one company offices? Give me the building names.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
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
Show the name of the building that has the most company offices.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
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
Which building has the largest number of company offices? Give me the building name.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories ASC
Please show the names of the buildings whose status is "on-hold", in ascending order of stories.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories ASC
Find the names of the buildings in "on-hold" status, and sort them in ascending order of building stories.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry
Please show each industry and the corresponding number of companies in that industry.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry
Whah are the name of each industry and the number of companies in that industry?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC
Please show the industries of companies in descending order of the number of companies.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC
Sort all the industries in descending order of the count of companies in each industry
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1
List the industry shared by the most companies.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1
Which industry has the most companies?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations)
List the names of buildings that have no company office.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations)
Which buildings do not have any company office? Give me the building names.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China"
Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China".
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China"
Which industries have both companies with headquarter in "USA" and companies with headquarter in "China"?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate"
Find the number of companies whose industry is "Banking" or "Conglomerate",
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate"
How many companies are in either "Banking" industry or "Conglomerate" industry?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2
Show the headquarters shared by more than two companies.
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
company_office
SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2
Which headquarter locations are used by more than 2 companies?
[Schema (values) (types)]: | company_office | buildings : id (text) , name (number) , city (text) , height (text) , stories (number) , status (number) | Companies : id (text) , name (number) , headquarters (text) , industry (text) , sales_billion (number) , profits_billion (number) , assets_billion (text) , market_value_billion (number) | Office_locations : building_id (text) , company_id (number) , move_in_year (text);
[Primary Keys]: buildings : id, companies : id, office_locations : building_id
[Foreign Keys]: office_locations : company_id = companies : id | office_locations : building_id = buildings : id
solvency_ii
SELECT count(*) FROM Products
How many products are there?
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Name FROM Products ORDER BY Product_Price ASC
List the name of products in ascending order of price.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Name , Product_Type_Code FROM Products
What are the names and type codes of products?
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy"
Show the prices of the products named "Dining" or "Trading Policy".
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT avg(Product_Price) FROM Products
What is the average price for products?
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1
What is the name of the product with the highest price?
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Type_Code , COUNT(*) FROM Products GROUP BY Product_Type_Code
Show different type codes of products and the number of products with each type code.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1
Show the most common type code across products.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2
Show the product type codes that have at least two products.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000
Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
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
Show the names of products and the number of events they are in.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
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
Show the names of products and the number of events they are in, sorted by the number of events in descending order.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
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
Show the names of products that are in at least two events.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
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
Show the names of products that are in at least two events in ascending alphabetical order of product name.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
solvency_ii
SELECT Product_Name FROM Products WHERE Product_ID NOT IN (SELECT Product_ID FROM Products_in_Events)
List the names of products that are not in any event.
[Schema (values) (types)]: | solvency_ii | Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id
entertainment_awards
SELECT count(*) FROM artwork
How many artworks are there?
[Schema (values) (types)]: | entertainment_awards | festival_detail : festival_id (text) , festival_name (number) , chair_name (text) , location (text) , year (text) , num_of_audience (number) | artwork : artwork_id (text) , type (number) , name (text) | nomination : artwork_id (text) , festival_id (number) , result (text);
[Primary Keys]: festival_detail : festival_id, artwork : artwork_id, nomination : artwork_id
[Foreign Keys]: nomination : festival_id = festival_detail : festival_id | nomination : artwork_id = artwork : artwork_id
entertainment_awards
SELECT Name FROM artwork ORDER BY Name ASC
List the name of artworks in ascending alphabetical order.
[Schema (values) (types)]: | entertainment_awards | festival_detail : festival_id (text) , festival_name (number) , chair_name (text) , location (text) , year (text) , num_of_audience (number) | artwork : artwork_id (text) , type (number) , name (text) | nomination : artwork_id (text) , festival_id (number) , result (text);
[Primary Keys]: festival_detail : festival_id, artwork : artwork_id, nomination : artwork_id
[Foreign Keys]: nomination : festival_id = festival_detail : festival_id | nomination : artwork_id = artwork : artwork_id