Management & CommerceModerateBusiness analyst · SQL test
Which statement about the logical order in which a SELECT query is evaluated is correct?
- A. WHERE runs before GROUP BY, HAVING after, so only HAVING sees aggregates
- B. HAVING is applied before WHERE, so it can filter rows before grouping
- C. A column alias defined in SELECT can always be used in the WHERE clause
- D. ORDER BY is applied before GROUP BY, so groups follow the sorted order
Correct answer: A. WHERE runs before GROUP BY, HAVING after, so only HAVING sees aggregates
Logical order: FROM/JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. WHERE cannot see aggregates or (in standard SQL) SELECT aliases, because they are computed later.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Table orders has 3 rows and table items has 6 rows. How many rows does SELECT FROM orders CROSS JOIN items return?
- Table emp(id, name, dept, salary, mgr) has rows (1, Asha, Sales, 90, NULL), (2, Ravi, Sales, 60, 1), (3, Meena, Sales, 75, 1), (4, Kiran…
- Table emp(id, name, dept, salary, mgr) has rows (1, Asha, Sales, 90, NULL), (2, Ravi, Sales, 60, 1), (3, Meena, Sales, 75, 1), (4, Kiran…
- Daily demand is a steady 50 units, the order quantity is 200 units, and the supplier's lead time is 10 days. At what on-hand stock level…
- Lead-time demand is normal with a standard deviation of 40 units, and the firm holds 60 units of safety stock. What cycle-service level…
- Product X (lead time 1 week) needs 2 units of Y; Y (lead time 2 weeks) needs 3 units of Z; Z has a lead time of 1 week. 100 units of X are…