
DB-TASK-002
Let me explain it with some "DVD Rental DataBase" qns QN : 1 Get all movies with rental rate greater than 3 . SELECT * FROM film WHERE rental_rate > 3 it is to select all columns from film table and condition is rental_rate greater than 3 QN: 2 Movies with rental rate > 3 and replacement cost < 20. ANS : SELECT * FROM film WHERE rental_rate > 3 AND replacement_cost < 20 ; two conditions are given so we use AND to combine both. QN: 3 Movies rated PG or rental rate 0.99. ANS : SELECT * FROM film WHERE rating = 'PG' OR rental_rate = 0 . 99 ; either one condition can be true so we use OR. QN: 4 First 10 movies sorted by rental rate (highest first). ANS : SELECT * FROM film ORDER BY rental_rate DESC LIMIT 10 ; since, we sort rental_rate in descending and take first 10. QN: 5 Skip first 5 and get next 3 (ascending). ANS : SELECT * FROM film ORDER BY rental_rate ASC OFFSET 5 LIMIT 3 ; OFFSET skips first 5 rows then LIMIT gives next 3. QN: 6 Skip first 5 and get next 3 (ascending). ANS : SELEC
Continue reading on Dev.to DevOps
Opens in a new tab




