Lab Tasks: Consider the Branch table as follows. branchNo | street | city | post
ID: 3595121 • Letter: L
Question
Lab Tasks: Consider the Branch table as follows. branchNo | street | city | postcode | employees B005 | 22 Deer Rd | London | SW1 4EH | 18 B007 | 189 Hudson St | Boston | 49553 | 22 B003 | 244 Broadway St | Glasgow | 21577 | 12 B004 | 250 5TH Av | New York | 10013 | 32 B002 | 990 54TH St | London | 07306 | 26 ------------------------------------------------------- Task 1: Create the Branch table using the following code. CREATE TABLE Branch ( branchNo VARCHAR2(4), street VARCHAR2(20), city VARCHAR2(15), postcode VARCHAR2(10), employees NUMBER ); ------------------------------------------------------- Task 2: Insert the first record into the Branch table using the folowing code. INSERT INTO Branch VALUES('B005', '22 Deer Rd', 'London', 'SW1 4EH', '18'); ------------------------------------------------------- Task 3: List the content of the table Branch using: SELECT * FROM Branch; ------------------------------------------------------- Task 4: Insert the remaining 4 records into the Branch table. ------------------------------------------------------- Task 5: List the content of the table Branch. ------------------------------------------------------- Task 6: Write SQL statements to list the followings: a- The branchNo, the street and the city of branches from London or Glasgow cities. b- The branchNo, the city, and the employees sorted by employees is descendent order. c- The branchNo, the street, the city and the employees of branches with number of employees between 18 and 30.
Explanation / Answer
Task 1:
CREATE TABLE Branch (
branchNo VARCHAR2(4),
street VARCHAR2(20),
city VARCHAR2(15),
postcode VARCHAR2(10),
employees NUMBER
);
Task2:
INSERT INTO Branch VALUES('B005', '22 Deer Rd', 'London', 'SW1 4EH', '18');
Task3:
SELECT * FROM Branch;
Task 4:
INSERT INTO Branch VALUES('B007', '189 Hudson St', 'Boston', '49553', '22');
INSERT INTO Branch VALUES('B003', '244 Broadway St', 'Glasgow', '21577', '12');
INSERT INTO Branch VALUES('B004', '250 5TH Av', 'New York', '10013', '32');
INSERT INTO Branch VALUES('B002', '990 54TH St', 'London', '07306', '26');
Task 5:
SELECT * FROM Branch;
Task 6:
a- SELECT branchNo,street,city FROM Branch WHERE city in ('London','Glasgow');
b- SELECT branchNo,street,employees FROM Branch ORDER BY employees DESC;
c- SELECT branchNo,street,city,employees FROM employees BETWEEN 18 and 30;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.