Question: Q3. In the sql file below find and correct all the errors in the code. Do not change, add or remove columns/attributes. Also execute the
Q3. In the sql file below find and correct all the errors in the code. Do not change, add or remove columns/attributes. Also execute the tasks below:
-Find the average, minimum and maximum price in the items table.
-Find the total stock in the store
-Display the distinct values of staff names from the Sale table.
The code:
create table ITEM ( Name int(10) NOT NULL, DESCRIP enum(20), PRICE NUMBER(6,2), PRIMARY KEY (Name));
insert into item values ('K3', 'Knife set', 17.95); insert into item values ('K3', 'Knife set', 17.95); insert into item values ('K5', 'Ladle',6.95); insert into item values ('K11', 'Scraper', 0.95); insert into item values ('L12', 'Rack', 22.95); insert into item values ('L3', 'Table', 399.5); insert into item values ('L6', 'Stool', 17.95);
/* * the sale table. * --- the 'date' attribute is replaced by 'sdate', * --- for 'date' is a reserved word in oracle. */
create table SALE (ITEM_NAME CHAR(1) NOT NULL, STAFF CHAR(20) NOT NULL, NUMSOLD NUMBER(5) NOT NULL, CLIENT CHAR(20) NOT NULL, SDATE INTEGER NOT NULL, PRIMARY KEY (ITEM_NAME, STAFF, NUMSOLD, CLIENT,SDATE));
insert into sale values ('K3', 'Simon', 6, 'Clark', 19980311);
insert into sale values ('K11', 'Simon', 1,'Cilla', 19980121);
insert into sale values ('K11', 'Simon', 1, 'Cilla', 19980123);
insert into sale values ('L12', 'Sorcha', 5, 'Charles', 19971130);
insert into sale values ('K3', 'Sean', 1, 'Clive', 19980221);
insert into sale values ('L12', 'Sean', 1, 'Cilla', 19980201);
insert into sale values ('L12', 'Simon', 2, 'Clive', 19980228);
insert into sale values ('K3', 'Sean', 2, 'Charles', 19971129);
insert into sale values ('K3', 'Simon', 6, 'Clark', 19980311);
/* * the staff table */
create table STAFF ( NAME CHAR(20) NOT NULL, POSITION CHAR(20), PRIMARY KEY (NAME));
insert into staff values(6, 'Manager');
insert into staff values('Simon', 'Clerk');
insert into staff values('Steve', 'Packer');
insert into staff values('Sean', 'Clerk');
insert into staff values('Sorcha', 'Director');
insert into staff values('Sian', 'Clerk');
/* * the stock table */
create table STOCK ( NAME CHAR(0) NOT NULL, NUMSTOCK NUMBER(5), PRIMARY KEY (NAME));
insert into stock values('K3', 105);
insert into stock values('K11', 66);
insert into stock values('L3', 0);
insert into stock values('L12', 4);
insert into stock values('L6', 13);
insert into stock values(null, 13);
/* * the client table */
create table CLIENT ( NAME CHAR(20) NOT NULL, ADDRESS CHAR(20), PRIMARY KEY (NAME)); insert into client values('Clive', 'India Rd');
insert into client values(0, 'Kent St');
insert into client values('Clark', 'Kent St');
insert into client values('Charles', 'Windsor Av');
insert into client values('Cilla', 'Black St');
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
