Microsoft Azure Data FundamentalsDescribe how to work with relational data on AzureEasy

A data analyst is querying an Azure SQL Database that contains customer order data. They need to retrieve all orders placed in the last 30 days. Which SQL clause is most appropriate for filtering the results based on the order date?

  1. AHAVING
  2. BORDER BY
  3. CGROUP BY
  4. DWHERE
Show answer & explanation

Correct answer: D. WHERE

The WHERE clause is used to filter rows based on a specified condition before any grouping or ordering takes place.

Why the other options are wrong

  • A. HAVING is used to filter groups based on an aggregate condition, typically used after a GROUP BY clause.
  • B. ORDER BY is used to sort the result set of a query in ascending or descending order.
  • C. GROUP BY is used to aggregate rows that have the same values in specified columns into a summary row.

SQL WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified condition in a SQL query.

  • Filters rows before aggregation.
  • Applies to individual rows.
  • Uses comparison operators (e.g., =, >, <, LIKE, BETWEEN).

Memory trick: WHERE is for rows, HAVING is for groups, ORDER for order.

More Describe how to work with relational data on Azure questions