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

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…

Contents