DEV Community

Santhosh V
Santhosh V

Posted on

CA 32 - Filter Assignments

Today I practiced writing SQL queries using different conditions. This helped me understand how to filter data properly.

First, I used conditions like WHERE to get movies with rental rate greater than 3, or based on multiple conditions like rental rate and replacement cost.

Then I learned using AND / OR to combine conditions. For example, getting movies that are either rated “PG” or have a cheap rental rate.

I also practiced sorting and limiting using ORDER BY, LIMIT, and OFFSET. Like showing top 10 movies or skipping some and getting the next few.

Next, I used BETWEEN to find movies within a range (like rental duration between 3 and 7 days).

I also tried pattern matching using LIKE, such as:

Titles starting with “A”
Titles ending with “e”
Titles containing words like “Man” or “Woman”

Then I worked with NULL values, like finding customers without email or movies without special features.

I also filtered data using dates, like finding rentals between two dates.

WHERE - filter data
AND / OR - combine conditions
ORDER BY - sort
LIMIT & OFFSET - control results
BETWEEN - range filter
LIKE - pattern search
NULL - missing values

Top comments (0)