db_id stringclasses 146
values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146
values |
|---|---|---|---|
document_management | What are the names of all the documents, as well as the access counts of each, ordered alphabetically? | SELECT document_name , access_count FROM documents ORDER BY document_name | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | 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? | SELECT document_name , access_count FROM documents ORDER BY access_count DESC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | 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? | SELECT document_name , access_count FROM documents ORDER BY access_count DESC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the types of documents with more than 4 documents. | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 4 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the codes of types of documents of which there are for or more? | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 4 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the total access count of all documents in the most popular document type. | SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the total access count of documents that are of the most common document type? | SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the average access count of documents? | SELECT avg(access_count) FROM documents | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the average access count across all documents? | SELECT avg(access_count) FROM documents | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the structure of the document with the least number of accesses? | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Return the structure description of the document that has been accessed the fewest number of times. | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the type of the document named "David CV"? | SELECT document_type_code FROM documents WHERE document_name = "David CV" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Return the type code of the document named "David CV". | SELECT document_type_code FROM documents WHERE document_name = "David CV" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the list of documents that are both in the most three popular type and have the most three popular structure. | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the names of documents that have both one of the three most common types and one of three most common structures? | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What document types do have more than 10000 total access number. | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count) > 10000 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Return the codes of the document types that do not have a total access count of over 10000. | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count) > 10000 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are all the section titles of the document named "David CV"? | 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" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Give the section titles of the document with the name "David CV". | 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" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find all the name of documents without any sections. | SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections) | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the names of documents that do not have any sections? | SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections) | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | List all the username and passwords of users with the most popular role. | SELECT user_name , password FROM users GROUP BY role_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the usernames and passwords of users that have the most common role? | SELECT user_name , password FROM users GROUP BY role_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the average access counts of documents with functional area "Acknowledgement". | 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" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the average access counts of documents that have the functional area description "Acknowledgement"? | 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" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find names of the document without any images. | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the names of documents that do not have any images? | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the name of the document with the most number of sections? | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Return the name of the document that has the most sections. | 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 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | List all the document names which contains "CV". | SELECT document_name FROM documents WHERE document_name LIKE "%CV%" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the names of documents that contain the substring "CV"? | SELECT document_name FROM documents WHERE document_name LIKE "%CV%" | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | How many users are logged in? | SELECT count(*) FROM users WHERE user_login = 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Count the number of users that are logged in. | SELECT count(*) FROM users WHERE user_login = 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the description of the most popular role among the users that have logged in. | 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) | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the description of the most popular role among users that have logged in? | 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) | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the average access count of documents with the least popular structure. | SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What is the average access count of documents that have the least common structure? | SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | List all the image name and URLs in the order of their names. | SELECT image_name , image_url FROM images ORDER BY image_name | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the names and urls of images, sorted alphabetically? | SELECT image_name , image_url FROM images ORDER BY image_name | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Find the number of users in each role. | SELECT count(*) , role_code FROM users GROUP BY role_code | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What are the different role codes for users, and how many users have each? | SELECT count(*) , role_code FROM users GROUP BY role_code | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | What document types have more than 2 corresponding documents? | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 2 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
document_management | Give the codes of document types that have more than 2 corresponding documents. | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*) > 2 | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
company_office | How many companies are there? | SELECT count(*) FROM Companies | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Count the number of companies. | SELECT count(*) FROM Companies | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | List the names of companies in descending order of market value. | SELECT name FROM Companies ORDER BY Market_Value_billion DESC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Sort the company names in descending order of the company's market value. | SELECT name FROM Companies ORDER BY Market_Value_billion DESC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | What are the names of companies whose headquarters are not "USA"? | SELECT name FROM Companies WHERE Headquarters != 'USA' | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Find the names of the companies whose headquarters are not located in "USA". | SELECT name FROM Companies WHERE Headquarters != 'USA' | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | What are the name and assets of each company, sorted in ascending order of company name? | SELECT name , Assets_billion FROM Companies ORDER BY name ASC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | List the name and assets of each company in ascending order of company name. | SELECT name , Assets_billion FROM Companies ORDER BY name ASC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | What are the average profits of companies? | SELECT avg(Profits_billion) FROM Companies | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Compute the average profits companies make. | SELECT avg(Profits_billion) FROM Companies | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | What are the maximum and minimum sales of the companies whose industries are not "Banking". | SELECT max(Sales_billion) , min(Sales_billion) FROM Companies WHERE Industry != "Banking" | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Find the maximum and minimum sales of the companies that are not in the "Banking" industry. | SELECT max(Sales_billion) , min(Sales_billion) FROM Companies WHERE Industry != "Banking" | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | How many different industries are the companies in? | SELECT count(DISTINCT Industry) FROM Companies | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Count the number of distinct company industries. | SELECT count(DISTINCT Industry) FROM Companies | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | List the names of buildings in descending order of building height. | SELECT name FROM buildings ORDER BY Height DESC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | What are the names of buildings sorted in descending order of building height? | SELECT name FROM buildings ORDER BY Height DESC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Find the stories of the building with the largest height. | SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | What is the stories of highest building? | SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | List the name of a building along with the name of a company whose office is in the building. | 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 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | For each company, return the company name and the name of the building its office is located in. | 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 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Show the names of the buildings that have more than one company offices. | 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 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Which buildings have more than one company offices? Give me the building names. | 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 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Show the name of the building that has the most company offices. | 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 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Which building has the largest number of company offices? Give me the building name. | 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 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Please show the names of the buildings whose status is "on-hold", in ascending order of stories. | SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories ASC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Find the names of the buildings in "on-hold" status, and sort them in ascending order of building stories. | SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories ASC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Please show each industry and the corresponding number of companies in that industry. | SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Whah are the name of each industry and the number of companies in that industry? | SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Please show the industries of companies in descending order of the number of companies. | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Sort all the industries in descending order of the count of companies in each industry | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | List the industry shared by the most companies. | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Which industry has the most companies? | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | List the names of buildings that have no company office. | SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations) | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Which buildings do not have any company office? Give me the building names. | SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations) | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China". | SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Which industries have both companies with headquarter in "USA" and companies with headquarter in "China"? | SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Find the number of companies whose industry is "Banking" or "Conglomerate", | SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | How many companies are in either "Banking" industry or "Conglomerate" industry? | SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Show the headquarters shared by more than two companies. | SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
company_office | Which headquarter locations are used by more than 2 companies? | SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 | CREATE TABLE "buildings" (
"id" int,
"name" text,
"City" text,
"Height" int,
"Stories" int,
"Status" text,
PRIMARY KEY("id")
)
3 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
3 Punto Chapultepec Mexico City 210 59 proposed
CREATE TABLE "Companies" (
"id" int,
"name" text,
"Headquarters" text,
"Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value_billion" text,
PRIMARY KEY ("id")
)
3 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
3 General Electric USA Conglomerate 156.2 11.6 751.2 216.2
CREATE TABLE "Office_locations" (
"building_id" int,
"company_id" int,
"move_in_year" int,
PRIMARY KEY ("building_id", "company_id"),
FOREIGN KEY ("building_id") REFERENCES "buildings"("id"),
FOREIGN KEY ("company_id") REFERENCES "Companies"("id")
)
3 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
3 4 2023
|
solvency_ii | How many products are there? | SELECT count(*) FROM Products | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | List the name of products in ascending order of price. | SELECT Product_Name FROM Products ORDER BY Product_Price ASC | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | What are the names and type codes of products? | SELECT Product_Name , Product_Type_Code FROM Products | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the prices of the products named "Dining" or "Trading Policy". | SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy" | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | What is the average price for products? | SELECT avg(Product_Price) FROM Products | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | What is the name of the product with the highest price? | SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show different type codes of products and the number of products with each type code. | SELECT Product_Type_Code , COUNT(*) FROM Products GROUP BY Product_Type_Code | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the most common type code across products. | SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the product type codes that have at least two products. | SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000. | SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the names of products and the number of events they are in. | 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 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the names of products and the number of events they are in, sorted by the number of events in descending order. | 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 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the names of products that are in at least two events. | 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 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | Show the names of products that are in at least two events in ascending alphabetical order of product name. | 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 | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
solvency_ii | List the names of products that are not in any event. | SELECT Product_Name FROM Products WHERE Product_ID NOT IN (SELECT Product_ID FROM Products_in_Events) | CREATE TABLE Addresses (
Address_ID INTEGER NOT NULL ,
address_details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
)
3 rows from Addresses table:
Address_ID address_details
1 465 Emely Bypass\nWest Mafalda, CO 23309
2 669 Carter Trafficway\nPort Delbert, OK 66249
3 38247 Ernser Gateway Suite 442\nBogisichland, VT 71460
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
)
3 rows from Locations table:
Location_ID Other_Details
1 Rowe PLC
2 Ebert, Green and Bogisich
3 Prohaska LLC
CREATE TABLE Products (
Product_ID INTEGER NOT NULL,
Product_Type_Code CHAR(15),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
)
3 rows from Products table:
Product_ID Product_Type_Code Product_Name Product_Price
1 Books Business Policy 1336.26
3 Food Special Dinning 2894.94
5 Clothes Men suits 3298.84
CREATE TABLE Parties (
Party_ID INTEGER NOT NULL,
Party_Details VARCHAR(255),
PRIMARY KEY (Party_ID)
)
3 rows from Parties table:
Party_ID Party_Details
3 European People's Party
4 European Free Alliance
5 European Alliance for Freedom
CREATE TABLE Assets (
Asset_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Asset_ID)
)
3 rows from Assets table:
Asset_ID Other_Details
1 Transportation Cars
2 Meeting Rooms
3 Dinning Tables
CREATE TABLE Channels (
Channel_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Channel_ID)
)
3 rows from Channels table:
Channel_ID Other_Details
1 145
2 348
3 933
CREATE TABLE Finances (
Finance_ID INTEGER NOT NULL ,
Other_Details VARCHAR(255),
PRIMARY KEY (Finance_ID)
)
3 rows from Finances table:
Finance_ID Other_Details
1 Mutual
2 Good
3 Bad
CREATE TABLE Events (
Event_ID INTEGER NOT NULL ,
Address_ID INTEGER,
Channel_ID INTEGER NOT NULL,
Event_Type_Code CHAR(15),
Finance_ID INTEGER NOT NULL,
Location_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID),
UNIQUE (Event_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Finance_ID) REFERENCES Finances (Finance_ID)
)
3 rows from Events table:
Event_ID Address_ID Channel_ID Event_Type_Code Finance_ID Location_ID
1 3 12 Trade Show 2 13
2 15 13 Press Conferenc 8 11
3 12 1 Press Conferenc 12 6
CREATE TABLE Products_in_Events (
Product_in_Event_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Product_in_Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
)
3 rows from Products_in_Events table:
Product_in_Event_ID Event_ID Product_ID
13 4 29
23 8 3
32 14 10
CREATE TABLE Parties_in_Events (
Party_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
Role_Code CHAR(15),
PRIMARY KEY (Party_ID, Event_ID),
FOREIGN KEY (Party_ID) REFERENCES Parties (Party_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Parties_in_Events table:
Party_ID Event_ID Role_Code
3 7 Organizer
3 8 Participant
4 1 Organizer
CREATE TABLE Agreements (
Document_ID INTEGER NOT NULL ,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Document_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Agreements table:
Document_ID Event_ID
1 13
2 13
3 15
CREATE TABLE Assets_in_Events (
Asset_ID INTEGER NOT NULL,
Event_ID INTEGER NOT NULL,
PRIMARY KEY (Asset_ID, Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Assets_in_Events table:
Asset_ID Event_ID
1 4
1 5
1 9
|
entertainment_awards | How many artworks are there? | SELECT count(*) FROM artwork | CREATE TABLE "festival_detail" (
"Festival_ID" int,
"Festival_Name" text,
"Chair_Name" text,
"Location" text,
"Year" int,
"Num_of_Audience" int,
PRIMARY KEY ("Festival_ID")
)
3 rows from festival_detail table:
Festival_ID Festival_Name Chair_Name Location Year Num_of_Audience
1 Panasonic Awards Raymond Floyd United States 2006 152
2 Flower Awards Charles Coody United States 2007 155
3 Cherry Awards Doug Ford United States 2007 160
CREATE TABLE artwork (
"Artwork_ID" int,
"Type" text,
"Name" text,
PRIMARY KEY ("Artwork_ID")
)
3 rows from artwork table:
Artwork_ID Type Name
1 Program Music/Variety Show Indonesian Idol
2 Program Music/Variety Show I Know
3 Presenter Music/Variety Show Loving you
CREATE TABLE nomination (
"Artwork_ID" int,
"Festival_ID" int,
"Result" text,
PRIMARY KEY ("Artwork_ID","Festival_ID"),
FOREIGN KEY ("Artwork_ID") REFERENCES `artwork`("Artwork_ID"),
FOREIGN KEY ("Festival_ID") REFERENCES `festival_detail`("Festival_ID")
)
3 rows from nomination table:
Artwork_ID Festival_ID Result
1 2 Nominated
2 2 Won
3 1 Nominated
|
entertainment_awards | List the name of artworks in ascending alphabetical order. | SELECT Name FROM artwork ORDER BY Name ASC | CREATE TABLE "festival_detail" (
"Festival_ID" int,
"Festival_Name" text,
"Chair_Name" text,
"Location" text,
"Year" int,
"Num_of_Audience" int,
PRIMARY KEY ("Festival_ID")
)
3 rows from festival_detail table:
Festival_ID Festival_Name Chair_Name Location Year Num_of_Audience
1 Panasonic Awards Raymond Floyd United States 2006 152
2 Flower Awards Charles Coody United States 2007 155
3 Cherry Awards Doug Ford United States 2007 160
CREATE TABLE artwork (
"Artwork_ID" int,
"Type" text,
"Name" text,
PRIMARY KEY ("Artwork_ID")
)
3 rows from artwork table:
Artwork_ID Type Name
1 Program Music/Variety Show Indonesian Idol
2 Program Music/Variety Show I Know
3 Presenter Music/Variety Show Loving you
CREATE TABLE nomination (
"Artwork_ID" int,
"Festival_ID" int,
"Result" text,
PRIMARY KEY ("Artwork_ID","Festival_ID"),
FOREIGN KEY ("Artwork_ID") REFERENCES `artwork`("Artwork_ID"),
FOREIGN KEY ("Festival_ID") REFERENCES `festival_detail`("Festival_ID")
)
3 rows from nomination table:
Artwork_ID Festival_ID Result
1 2 Nominated
2 2 Won
3 1 Nominated
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.