Informatics Practices
Write SQL commands for (a) to (d) and write the output for (e) on the basis of the following table:
Table: FURNITURE
| S NO | ITEM | TYPE | DATEOFSTOCK | PRICE | DISCOUNT |
|---|---|---|---|---|---|
| 1 | WhiteLotus | DoubleBed | 2002-02-23 | 3000 | 25 |
| 2 | Pinkfeathers | BabyCot | 2002-01-29 | 7000 | 20 |
| 3 | Dolphin | BabyCot | 2002-02-19 | 9500 | 20 |
| 4 | Decent | OfficeTable | 2002-02-01 | 25000 | 30 |
| 5 | Comfortzone | DoubleBed | 2002-02-12 | 25000 | 30 |
| 6 | Donald | BabyCot | 2002-02-24 | 6500 | 15 |
(a) To list the details of furniture whose price is more than 10000.
(b) To list the Item name and Price of furniture whose discount is between 10 and 20.
(c) To delete the record of all items where discount is 30.
(d) To display the price of 'Babycot'.
(e) Select Distinct Type from Furniture;
Relational Database
4 Likes
Answer
(a)
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 |
+----+-------------+-------------+-------------+-------+----------+
(b)
SELECT ITEM, PRICE
FROM FURNITURE
WHERE DISCOUNT BETWEEN 10 AND 20;
Output
+--------------+-------+
| ITEM | PRICE |
+--------------+-------+
| Pinkfeathers | 7000 |
| Dolphin | 9500 |
| Donald | 6500 |
+--------------+-------+
(c)
DELETE FROM FURNITURE WHERE DISCOUNT = 30;
(d)
SELECT PRICE
FROM FURNITURE
WHERE TYPE = 'BabyCot';
Output
+-------+
| PRICE |
+-------+
| 7000 |
| 9500 |
| 6500 |
+-------+
(e)
SELECT DISTINCT Type FROM Furniture;
Output
+-------------+
| Type |
+-------------+
| DoubleBed |
| BabyCot |
| OfficeTable |
+-------------+
Answered By
3 Likes
Related Questions
Differentiate between DDL and DML. Mention the two commands for each category.
Consider the given table and answer the questions.
Table: SchoolBus
Rtno Area_Covered Capacity Noofstudents Distance Transporter Charges 1 Vasant Kunj 100 120 10 Shivam Travels 3500 2 Hauz Khas 80 80 10 Anand Travels 3000 3 Pitampura 60 55 30 Anand Travels 4500 4 Rohini 100 90 35 Anand Travels 5000 5 Yamuna Vihar 50 60 20 Bhalla Travels 3800 6 Krishna Nagar 70 80 30 Yadav Travels 4000 7 Vasundhara 100 110 20 Yadav Travels 3500 8 Paschim Vihar 40 40 20 Speed Travels 3200 9 Saket 120 120 10 Speed Travels 3500 10 Janakpuri 100 100 20 Kisan Tours 3500 (a) To show all information of schoolbus where capacity is more than 70.
(b) To show area_covered for buses covering more than 20 km., but charges less than 4000.
(c) To display the details of school Bus having no. of students less than 50.
(d) To show Rtno, Area_Covered and Average cost per student for all routes where average cost per student is—Charges/Noofstudents.
(e) Add a new record with the following data:
(11, "Motibagh", 35, 32, 10, "Kisan Tours", 3500)
Write SQL commands for (a) to (d) and write the output for (e) and (f) on the basis of given table GRADUATE:
Table: GRADUATE
S NO NAME STIPEND SUBJECT AVERAGE RANK 1 KARAN 400 PHYSICS 68 1 2 RAJ 450 CHEMISTRY 68 1 3 DEEP 300 MATHS 62 2 4 DIVYA 350 CHEMISTRY 63 1 5 GAURAV 500 PHYSICS 70 1 6 MANAV 400 CHEMISTRY 55 2 7 VARUN 250 MATHS 64 1 8 LIZA 450 COMPUTER 68 1 9 PUJA 500 PHYSICS 62 1 10 NISHA 300 COMPUTER 57 2 (a) List the names of those students who have obtained rank 1.
(b) Display a list of all those names whose average is greater than 65.
(c) Display the names of those students who have opted for computer as a subject with average of more than 60.
(d) List the names of all students whose name ends with 'a'.
(e) SELECT * FROM GRADUATE WHERE Subject = "Physics";
(f) SELECT DISTINCT RANK FROM GRADUATE;
What is the difference between Candidate key and Alternate key?