0% found this document useful (0 votes)
8 views

Assignment05_Answers

Uploaded by

janithadilsham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment05_Answers

Uploaded by

janithadilsham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSSIGNMENT_5 ANSWERS

(01).
SHOW DATABASES;
USE school_items;

(02).
SHOW TABLES;

(03).
SELECT * FROM item;

(04).
SELECT * FROM bookShop;

(05).
SELECT * FROM distribute;

(06).
CREATE TABLE customer(cuCode char(4), name varchar(25),
address varchar(25));

INSERT INTO customer VALUES("C01", "Thisath", "Matara");


INSERT INTO customer VALUES("C02", "Nipuna", "Colombo");
INSERT INTO customer VALUES("C03", "Samadi", "Kandy");

(07).
ALTER TABLE sales ADD cuCode char(4);

(08).
DESC sales;

(09).
UPDATE sales SET cuCode = 'C01' WHERE billNo IN('B1', 'B4',
'B5');
UPDATE sales SET cuCode = 'C03' WHERE billNo = 'B2';
UPDATE sales SET cuCode = 'C02' WHERE billNo = 'B3';

(10).
ALTER TABLE bookShop MODIFY COLUMN bsName varchar(30);

(11).
SELECT MAX(salesDate) FROM sales;

(12).
SELECT i.itName, i.price, d.bsCode, i.itCode FROM item AS i,
distribute AS d WHERE d.itCode=i.itCode AND d.bsCode IN('BS01',
'BS02') ORDER BY i.price DESC;

1
ASSSIGNMENT_5 ANSWERS

(13).
SELECT itName, price, bsCode FROM item, distribute WHERE
distribute.itCode=item.itCode AND bsCode IN ('BS01', 'BS02')
ORDER BY bsCode DESC;

(14).
SELECT sum(salesQty) FROM item, sales WHERE
item.itCode=sales.itCode AND itName='Stapler';

(15).
SELECT SUM(qty) FROM distribute, bookShop WHERE
distribute.bsCode = bookShop.bsCode AND bsName='Sarasavi';

(16).
SELECT max(price) FROM item;

(17).
SELECT itName FROM item ORDER BY price DESC LIMIT 1;

(18).
SELECT (price*0.9) * 10 AS TotalAmount FROM item WHERE
itCode = 'IT11';

(19).
UPDATE item SET price = price + 5.00 WHERE itCode in
('IT11', 'IT10');

(20).
SELECT itCode, itName FROM item WHERE brand IS NOT NULL;

(21).
SELECT itCode, SUM(qty) AS TotalQty FROM distribute GROUP BY
itCode;

(22).
SELECT i.itName, SUM(d.qty) AS TotalQuantity FROM item AS i
JOIN distribute AS d ON i.itCode = d.itCode GROUP BY i.itName;

You might also like