CBSE Class 12 Computer Science Question 73 of 91

Relational Database and SQL — Question 34

Back to all questions
34
Question

Question 27

Write SQL Commands for (i) to (v) and write the outputs for (vi) to (viii) on the basis of the following table:

Table: FURNITURE

NOITEMTYPEDATEOFSTOCKPRICEDISCOUNT
1White LotusDoubleBed2002-02-23300025
2PinkfeathersBabyCot2002-01-29700020
3DolphinBabyCot2002-02-19950020
4DecentOfficeTable2002-02-012500030
5ComfortzoneDoubleBed2002-02-122500030
6DonaldBabyCot2002-02-24650015

(i) To list the details of furniture whose price is more than 10000.

(ii) To list the Item name and Price of furniture whose discount is between 10 and 20.

(iii) To delete the record of all items where discount is 30.

(iv) To display the price of 'Babycot'.

(v) To list item name, type and price of all items whose names start with 'D'.

(vi) SELECT DISTINCT Type FROM Furniture;

(vii) SELECT MAX(Price) FROM Furniture WHERE DateofStock > '2002-02-15' ;

(viii) SELECT COUNT(*) FROM Furniture WHERE Discount < 25 ;

Answer

(i)

SELECT * FROM FURNITURE
WHERE PRICE > 10000;
Output
+----+-------------+-------------+-------------+-------+----------+
| NO | ITEM        | TYPE        | DATEOFSTOCK | PRICE | DISCOUNT |
+----+-------------+-------------+-------------+-------+----------+
|  4 | Decent      | OfficeTable | 2002-02-01  | 25000 |       30 |
|  5 | Comfortzone | DoubleBed   | 2002-02-12  | 25000 |       30 |
+----+-------------+-------------+-------------+-------+----------+

(ii)

SELECT ITEM, PRICE
FROM FURNITURE
WHERE DISCOUNT BETWEEN 10 AND 20;
Output
+--------------+-------+
| ITEM         | PRICE |
+--------------+-------+
| Pinkfeathers |  7000 |
| Dolphin      |  9500 |
| Donald       |  6500 |
+--------------+-------+

(iii)

DELETE FROM FURNITURE WHERE DISCOUNT = 30;

(iv)

SELECT PRICE
FROM FURNITURE
WHERE TYPE = 'BabyCot';
Output
+-------+
| PRICE |
+-------+
|  7000 |
|  9500 |
|  6500 |
+-------+

(v)

SELECT ITEM, TYPE, PRICE
FROM FURNITURE
WHERE ITEM LIKE 'D%';
Output
+---------+-------------+-------+
| ITEM    | TYPE        | PRICE |
+---------+-------------+-------+
| Dolphin | BabyCot     |  9500 |
| Decent  | OfficeTable | 25000 |
| Donald  | BabyCot     |  6500 |
+---------+-------------+-------+

(vi) SELECT DISTINCT Type FROM Furniture;

Output
+-------------+
| Type        |
+-------------+
| DoubleBed   |
| BabyCot     |
| OfficeTable |
+-------------+

(vii) SELECT MAX(Price) FROM Furniture WHERE DateofStock > '2002-02-15' ;

Output
+------------+
| MAX(Price) |
+------------+
|       9500 |
+------------+

(viii) SELECT COUNT(*) FROM Furniture WHERE Discount < 25 ;

Output
+----------+
| COUNT(*) |
+----------+
|        3 |
+----------+