Starting here? This lesson is part of a full-length tutorial in using SQL for Data Analysis. Check out the beginning.
In this lesson we'll cover:
AND is a logical operator in SQL that allows you to select only rows that satisfy two conditions. Using data from the Billboard Music Charts, the following query will return all rows for top-10 recordings in 2012.
SELECT * FROM tutorial.billboard_top_100_year_end WHERE year = 2012 AND year_rank <= 10
You can use SQL's
AND operator with additional
AND statements or any other comparison operator, as many times as you want. If you run this query, you'll notice that all of the requirements are satisfied.
SELECT * FROM tutorial.billboard_top_100_year_end WHERE year = 2012 AND year_rank <= 10 AND "group_name" ILIKE '%feat%'
You can see that this example is spaced out onto multiple lines—a good way to make long
WHERE clauses more readable.