CBSE Class 12 Computer Science
Question 23 of 78
Simple Queries in SQL — Question 16
Back to all questions 16
Question Write SQL commands for the following on the basis of given table MOV :
Table : MOV
| No | Title | Type | Rating | Stars | Qty | Price |
|---|---|---|---|---|---|---|
| 1 | Gone with the Wind | Drama | G | Gable | 4 | 39.95 |
| 2 | Friday the 13th | Horror | R | Jason | 2 | 69.95 |
| 3 | Top Gun | Drama | PG | Cruise | 7 | 49.95 |
| 4 | Splash | Comedy | PG13 | Hanks | 3 | 29.95 |
| 5 | Independence Day | Drama | R | Turner | 3 | 19.95 |
| 6 | Risky Business | Comedy | R | Cruise | 2 | 44.95 |
| 7 | Cocoon | Scifi | PG | Ameche | 2 | 31.95 |
| 8 | Crocodile Dundee | Comedy | PG13 | Harris | 2 | 69.95 |
| 9 | 101 Dalmatians | Comedy | G | 3 | 59.95 | |
| 10 | Tootsie | Comedy | PG | Hoffman | 1 | 29.95 |
- Display a list of all movies with Price over 20 and sorted by Price.
- Display all the movies sorted by QTY in decreasing order.
- Display a report listing a movie number, current value and replacement value for each movie in the above table. Calculate the replacement value for all movies as : QTY * Price * 1.15.
1.
SELECT Title
FROM MOV
WHERE Price > 20
ORDER BY Price ;+--------------------+
| Title |
+--------------------+
| Splash |
| Tootsie |
| Cocoon |
| Gone with the Wind |
| Risky Business |
| Top Gun |
| 101 Dalmatians |
| Friday the 13th |
| Crocodile Dundee |
+--------------------+
2.
SELECT Title
FROM MOV
ORDER BY Qty DESC ;+--------------------+
| Title |
+--------------------+
| Top Gun |
| Gone with the Wind |
| Splash |
| Independence Day |
| 101 Dalmatians |
| Friday the 13th |
| Risky Business |
| Cocoon |
| Crocodile Dundee |
| Tootsie |
+--------------------+
3.
SELECT No AS Movie_Number , Price AS Current_Value, (Qty * Price * 1.15) AS Replacement_Value
FROM MOV ;+--------------+---------------+--------------------+
| Movie_Number | Current_Value | Replacement_Value |
+--------------+---------------+--------------------+
| 1 | 39.95 | 183.77000350952147 |
| 2 | 69.95 | 160.884992980957 |
| 3 | 49.95 | 402.09750614166256 |
| 4 | 29.95 | 103.3275026321411 |
| 5 | 19.95 | 68.8275026321411 |
| 6 | 44.95 | 103.38500175476074 |
| 7 | 31.95 | 73.48500175476073 |
| 8 | 69.95 | 160.884992980957 |
| 9 | 59.95 | 206.8275026321411 |
| 10 | 29.95 | 34.44250087738037 |
+--------------+---------------+--------------------+