db_id
stringclasses
127 values
query
stringlengths
20
523
question
stringlengths
16
224
schema
stringclasses
127 values
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE product_stock_number LIKE "2%"
Find the names of all the products whose stock number starts with "2".
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE product_stock_number LIKE "2%"
Which catalog contents have a product stock number that starts from "2"? Show the catalog entry names.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.catalog_level_number = "8"
Find the names of catalog entries with level number 8.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.catalog_level_number = "8"
What are the names of catalog entries with level number 8?
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE LENGTH < 3 OR width > 5
Find the names of the products with length smaller than 3 or height greater than 5.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE LENGTH < 3 OR width > 5
Which catalog contents have length below 3 or above 5? Find the catalog entry names.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT t1.attribute_name , t1.attribute_id FROM Attribute_Definitions AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.attribute_id = t2.attribute_id WHERE t2.attribute_value = 0
Find the name and attribute ID of the attribute definitions with attribute value 0.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT t1.attribute_name , t1.attribute_id FROM Attribute_Definitions AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.attribute_id = t2.attribute_id WHERE t2.attribute_value = 0
Which attribute definitions have attribute value 0? Give me the attribute name and attribute ID.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name , capacity FROM Catalog_Contents WHERE price_in_dollars > 700
Find the name and capacity of products with price greater than 700 (in USD).
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name , capacity FROM Catalog_Contents WHERE price_in_dollars > 700
Which catalog contents has price above 700 dollars? Show their catalog entry names and capacities.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING count(*) > 1
Find the dates on which more than one revisions were made.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING count(*) > 1
On which days more than one revisions were made on catalogs.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT count(*) FROM catalog_contents
How many products are there in the records?
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT count(*) FROM catalog_contents
Find the total number of catalog contents.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE next_entry_id > 8
Name all the products with next entry ID greater than 8.
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE next_entry_id > 8
What are the catalog entry names of the products with next entry ID above 8?
PRAGMA foreign_keys = ON; CREATE TABLE `Attribute_Definitions` ( `attribute_id` INTEGER PRIMARY KEY, `attribute_name` VARCHAR(30), `attribute_data_type` VARCHAR(10) ); CREATE TABLE `Catalogs` ( `catalog_id` INTEGER PRIMARY KEY, `catalog_name` VARCHAR(50), `catalog_publisher` VARCHAR(80), `date_of_publication` DATETIME, `date_of_latest_revision` DATETIME ); CREATE TABLE `Catalog_Structure` ( `catalog_level_number` INTEGER PRIMARY KEY, `catalog_id` INTEGER NOT NULL, `catalog_level_name` VARCHAR(50), FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` ) ); CREATE TABLE `Catalog_Contents` ( `catalog_entry_id` INTEGER PRIMARY KEY, `catalog_level_number` INTEGER NOT NULL, `parent_entry_id` INTEGER, `previous_entry_id` INTEGER, `next_entry_id` INTEGER, `catalog_entry_name` VARCHAR(80), `product_stock_number` VARCHAR(50), `price_in_dollars` DOUBLE NULL, `price_in_euros` DOUBLE NULL, `price_in_pounds` DOUBLE NULL, `capacity` VARCHAR(20), `length` VARCHAR(20), `height` VARCHAR(20), `width` VARCHAR(20), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); CREATE TABLE `Catalog_Contents_Additional_Attributes` ( `catalog_entry_id` INTEGER NOT NULL, `catalog_level_number` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, `attribute_value` VARCHAR(255) NOT NULL, FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ), FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` ) ); INSERT INTO Attribute_Definitions (`attribute_id`, `attribute_name`, `attribute_data_type`) VALUES (1, 'Green', 'Bool')INSERT INTO Catalogs (`catalog_id`, `catalog_name`, `catalog_publisher`, `date_of_publication`, `date_of_latest_revision`) VALUES (1, 'Chocolate', 'Koepp-Rutherford handmade chocolate store', '2013-03-15 05:09:17', '2017-09-26 12:10:36')INSERT INTO Catalog_Structure (`catalog_level_number`, `catalog_id`, `catalog_level_name`) VALUES (1, 1, 'Category')INSERT INTO Catalog_Contents (`catalog_entry_id`, `catalog_level_number`, `parent_entry_id`, `previous_entry_id`, `next_entry_id`, `catalog_entry_name`, `product_stock_number`, `price_in_dollars`, `price_in_euros`, `price_in_pounds`, `capacity`, `length`, `height`, `width`) VALUES (1, 1, 5, 9, 7, 'Cola', '89 cp', '200.78', '159.84', '172.17', '1', '3', '9', '5')INSERT INTO Catalog_Contents_Additional_Attributes (`catalog_entry_id`, `catalog_level_number`, `attribute_id`, `attribute_value`) VALUES (5, 8, 4, '1')
flight_1
SELECT count(*) FROM Aircraft
How many aircrafts do we have?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Aircraft
How many aircrafts exist in the database?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , distance FROM Aircraft
Show name and distance for all aircrafts.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , distance FROM Aircraft
What are the names and distances for all airplanes?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT aid FROM Aircraft WHERE distance > 1000
Show ids for all aircrafts with more than 1000 distance.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT aid FROM Aircraft WHERE distance > 1000
What are the ids of all aircrafts that can cover a distance of more than 1000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000
How many aircrafts have distance between 1000 and 5000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000
What is the count of aircrafts that have a distance between 1000 and 5000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , distance FROM Aircraft WHERE aid = 12
What is the name and distance for aircraft with id 12?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , distance FROM Aircraft WHERE aid = 12
What is the name and distance for the aircraft that has an id of 12?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT min(distance) , avg(distance) , max(distance) FROM Aircraft
What is the minimum, average, and maximum distance of all aircrafts.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT min(distance) , avg(distance) , max(distance) FROM Aircraft
Return the minimum, average and maximum distances traveled across all aircrafts.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT aid , name FROM Aircraft ORDER BY distance DESC LIMIT 1
Show the id and name of the aircraft with the maximum distance.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT aid , name FROM Aircraft ORDER BY distance DESC LIMIT 1
What is the id and name of the aircraft that can cover the maximum distance?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Aircraft ORDER BY distance LIMIT 3
Show the name of aircrafts with top three lowest distances.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Aircraft ORDER BY distance LIMIT 3
What are the aircrafts with top 3 shortest lengthes? List their names.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Aircraft WHERE distance > (SELECT avg(distance) FROM Aircraft)
Show names for all aircrafts with distances more than the average.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Aircraft WHERE distance > (SELECT avg(distance) FROM Aircraft)
What are the names of all aircrafts that can cover more distances than average?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Employee
How many employees do we have?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Employee
What is the number of employees?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , salary FROM Employee ORDER BY salary
Show name and salary for all employees sorted by salary.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , salary FROM Employee ORDER BY salary
What is the name and salary of all employees in order of salary?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid FROM Employee WHERE salary > 100000
Show ids for all employees with at least 100000 salary.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid FROM Employee WHERE salary > 100000
What is the id of every employee who has at least a salary of 100000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000
How many employees have salary between 100000 and 200000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000
What is the number of employees that have a salary between 100000 and 200000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , salary FROM Employee WHERE eid = 242518965
What is the name and salary for employee with id 242518965?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name , salary FROM Employee WHERE eid = 242518965
What is the name and salary of the employee with the id 242518965?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT avg(salary) , max(salary) FROM Employee
What is average and maximum salary of all employees.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT avg(salary) , max(salary) FROM Employee
What is the average and largest salary of all employees?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1
Show the id and name of the employee with maximum salary.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1
What is the id and name of the employee with the highest salary?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Employee ORDER BY salary ASC LIMIT 3
Show the name of employees with three lowest salaries.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Employee ORDER BY salary ASC LIMIT 3
What is the name of the 3 employees who get paid the least?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Employee WHERE salary > (SELECT avg(salary) FROM Employee)
Show names for all employees with salary more than the average.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT name FROM Employee WHERE salary > (SELECT avg(salary) FROM Employee)
What are the names of all employees who have a salary higher than average?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid , salary FROM Employee WHERE name = 'Mark Young'
Show the id and salary of Mark Young.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid , salary FROM Employee WHERE name = 'Mark Young'
What is the id and salary of the employee named Mark Young?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Flight
How many flights do we have?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(*) FROM Flight
What is the number of flights?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno , origin , destination FROM Flight ORDER BY origin
Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno , origin , destination FROM Flight ORDER BY origin
What is the flight number, origin, and destination for all flights in alphabetical order by departure cities?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno FROM Flight WHERE origin = "Los Angeles"
Show all flight number from Los Angeles.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno FROM Flight WHERE origin = "Los Angeles"
What are the numbers of all flights coming from Los Angeles?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin FROM Flight WHERE destination = "Honolulu"
Show origins of all flights with destination Honolulu.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin FROM Flight WHERE destination = "Honolulu"
What are the origins of all flights that are headed to Honolulu?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT departure_date , arrival_date FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
Show me the departure date and arrival date for all flights from Los Angeles to Honolulu.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT departure_date , arrival_date FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
What are the departure and arrival dates of all flights from LA to Honolulu?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno FROM Flight WHERE distance > 2000
Show flight number for all flights with more than 2000 distance.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno FROM Flight WHERE distance > 2000
What are the numbers of all flights that can cover a distance of more than 2000?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT avg(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
What is the average price for flights from Los Angeles to Honolulu.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT avg(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
What is the average price for flights from LA to Honolulu?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin , destination FROM Flight WHERE price > 300
Show origin and destination for flights with price higher than 300.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin , destination FROM Flight WHERE price > 300
What is the origin and destination for all flights whose price is higher than 300?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno , distance FROM Flight ORDER BY price DESC LIMIT 1
Show the flight number and distance of the flight with maximum price.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno , distance FROM Flight ORDER BY price DESC LIMIT 1
What is the flight number and its distance for the one with the maximum price?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno FROM Flight ORDER BY distance ASC LIMIT 3
Show the flight number of flights with three lowest distances.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT flno FROM Flight ORDER BY distance ASC LIMIT 3
What are the numbers of the shortest flights?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT avg(distance) , avg(price) FROM Flight WHERE origin = "Los Angeles"
What is the average distance and average price for flights from Los Angeles.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT avg(distance) , avg(price) FROM Flight WHERE origin = "Los Angeles"
What is the average distance and price for all flights from LA?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin , count(*) FROM Flight GROUP BY origin
Show all origins and the number of flights from each origin.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin , count(*) FROM Flight GROUP BY origin
For each origin, how many flights came from there?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT destination , count(*) FROM Flight GROUP BY destination
Show all destinations and the number of flights to each destination.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT destination , count(*) FROM Flight GROUP BY destination
What are the destinations and number of flights to each one?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin FROM Flight GROUP BY origin ORDER BY count(*) DESC LIMIT 1
Which origin has most number of flights?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT origin FROM Flight GROUP BY origin ORDER BY count(*) DESC LIMIT 1
What place has the most flights coming from there?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT destination FROM Flight GROUP BY destination ORDER BY count(*) LIMIT 1
Which destination has least number of flights?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT destination FROM Flight GROUP BY destination ORDER BY count(*) LIMIT 1
What destination has the fewest number of flights?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99
What is the aircraft name for the flight with number 99
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99
What is the name of the aircraft that was on flight number 99?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300"
Show all flight numbers with aircraft Airbus A340-300.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300"
What are the flight numbers for the aircraft Airbus A340-300?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T2.name , count(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid
Show aircraft names and number of flights for each aircraft.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T2.name , count(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid
What is the name of each aircraft and how many flights does each one complete?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING count(*) >= 2
Show names for all aircraft with at least two flights.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING count(*) >= 2
What are the names for all aircrafts with at least 2 flights?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(DISTINCT eid) FROM Certificate
How many employees have certificate.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT count(DISTINCT eid) FROM Certificate
What is the count of distinct employees with certificates?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate
Show ids for all employees who don't have a certificate.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate
What are the ids of all employees that don't have certificates?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T1.name = "John Williams"
Show names for all aircrafts of which John Williams has certificates.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T1.name = "John Williams"
What are the names of all aircrafts that John Williams have certificates to be able to fly?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800"
Show names for all employees who have certificate of Boeing 737-800.
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')
flight_1
SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800"
What are the names of all employees who have a certificate to fly Boeing 737-800?
-- drop table flight cascade constraints; -- drop table aircraft cascade constraints; -- drop table employee cascade constraints; -- drop table certificate cascade constraints; create table flight( flno number(4,0) primary key, origin varchar2(20), destination varchar2(20), distance number(6,0), departure_date date, arrival_date date, price number(7,2), aid number(9,0), foreign key("aid") references `aircraft`("aid")); create table aircraft( aid number(9,0) primary key, name varchar2(30), distance number(6,0)); create table employee( eid number(9,0) primary key, name varchar2(30), salary number(10,2)); create table certificate( eid number(9,0), aid number(9,0), primary key(eid,aid), foreign key("eid") references `employee`("eid"), foreign key("aid") references `aircraft`("aid")); INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1)Insert into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430')Insert into employee (EID,name,salary) values ('242518965','James Smith','120433')Insert into certificate (EID,AID) values ('11564812','2')