1. Learn
  2. /
  3. Courses
  4. /
  5. SQL Tutorial for Marketers

Exercise

Filtering Your Results

Congrats on completing the first chapter of this tutorial!

Now you know how to select one or multiple columns and perform basic counts with the help of SELECT and FROM, you'll put your focus on filtering your results in this chapter. Because, as you well know, you might want to only consider specific groups of clients of your marketing campaign. Your target group might have a specific age, gender, education level, ...

That's where the keyword WHERE comes in: you can use it to filter based on both text and numeric values in a table.

Here are some of the different comparison operators that you can use in combination with WHERE:

  • = equal
  • <> not equal
  • < less than
  • > greater than
  • <= less than or equal to
  • >= greater than or equal to

Let's look at an example, where you can filter text records such as education. The following code returns all bank clients that have a university degree:

SELECT education
FROM clients
WHERE education = 'university degree';

Notice that you actually build on the queries that you have seen before: the WHERE clause always comes after the FROM statement!

Note that in this course, you will use <> and not != for the not equal operator, as per the SQL standard.


Now, what does the following query return?

SELECT education
FROM clients
WHERE age > 30;

Instructions

100 XP

Possible answers