From the course: SQL for Non-Programmers
Unlock the full course today
Join today to access over 23,100 courses taught by industry experts.
Filtering your data with WHERE - SQL Tutorial
From the course: SQL for Non-Programmers
Filtering your data with WHERE
To make our queries useful, we want to retrieve only the data that is relevant to our needs. The WHERE clause in SQL is placed after the FROM clause, and allows you to filter and retrieve specific data from a table that matches certain conditions. Let's try the WHERE clause together in SLS. Continuing with our query, selecting order data from the sales table, order number, employee name, product category, and order total. We were also ordering the data by order total descending and limiting to the top five rows. By executing this, we can see that the top five orders were for the product category olive oil. But what if management is not interested in olive oil product sales and would rather understand top orders for the bath products category? How can we uncover this in our sales data table? We can use the WHERE clause to filter on specific data. Going to the next section, we can take our previous query and add a new line after the FROM clause, WHERE plus the filter condition. In this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Getting started with SQL5m 33s
-
(Locked)
Retrieving data with SELECT7m 19s
-
(Locked)
Formatting your query5m 40s
-
(Locked)
Putting order to your data with ORDER BY6m 52s
-
(Locked)
Filtering your data with WHERE5m 9s
-
(Locked)
Filtering your data with multiple conditions8m 5s
-
(Locked)
Challenge: Practice with basic commands1m 40s
-
(Locked)
Solution: Basic commands solved4m 9s
-
-
-
-
-