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

A data analyst is working with an Azure SQL Database that contains customer order information. They need to retrieve all orders placed within the last 30 days. Which SQL clause should the analyst use to filter the results based on the order date?

  1. AHAVING
  2. BWHERE
  3. CGROUP BY
  4. DORDER BY
Show answer & explanation

Correct answer: B. WHERE

The WHERE clause is used to filter records based on specified conditions, making it the correct choice for selecting orders within a specific date range.

Why the other options are wrong

  • A. HAVING is used to filter groups of rows after aggregation, not individual rows before aggregation.
  • C. GROUP BY is used to group rows that have the same values into summary rows, not for filtering individual records.
  • D. ORDER BY is used to sort the result set of a query, not for filtering.

SQL WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified condition from a database table.

  • Filters rows before grouping or aggregation.
  • Follows the FROM clause.
  • Can use comparison operators (>, <, =, LIKE, BETWEEN, etc.).

Memory trick: SELECT FROM WHERE GROUP HAVING ORDER – 'SeF WHy GHOstly ORder'

More Describe how to work with relational data on Azure questions