Microsoft Certified: Fabric Analytics Engineer AssociateExplore and analyze data (15-20%)Easy
A data analyst needs to retrieve all customer records from a `Customers` table where the `Country` column is 'USA' and the `LastPurchaseDate` is after January 1, 2023. Which SQL clause should be used to filter the rows based on these conditions?
- AWHERE
- BHAVING
- CORDER BY
- DGROUP BY
Show answer & explanationAnswer & explanation
Correct answer: A. WHERE
The WHERE clause is used to filter records that fulfill a specified condition or conditions. It is applied to individual rows before any grouping occurs.
Why the other options are wrong
- B. HAVING is used to filter groups based on specified conditions, typically after a GROUP BY clause.
- C. ORDER BY is used to sort the result-set in ascending or descending order.
- D. GROUP BY is used to group rows that have the same values into summary rows.
SQL WHERE Clause
The SQL WHERE clause is used to extract only those records that fulfill a specified condition.
- Filters rows before grouping.
- Can combine multiple conditions using AND, OR, NOT.
- Essential for precise data retrieval.
Memory trick: Select From Where Group Having Order — So F**king What, Get Hired On!