CS FundamentalsHardAccenture · Capgemini technical pattern

Which of these queries is NOT valid in standard SQL?

  1. A. SELECT cust, amount FROM Orders GROUP BY cust;
  2. B. SELECT cust, SUM(amount) FROM Orders GROUP BY cust;
  3. C. SELECT cust FROM Orders GROUP BY cust HAVING MAX(amount) > 300;
  4. D. SELECT COUNT(*) FROM Orders;

Correct answer: A. SELECT cust, amount FROM Orders GROUP BY cust;

With GROUP BY, every selected column must be grouped or aggregated; amount is neither, and a group like Ana has two different amounts. (MySQL’s loose mode may accept it and pick an arbitrary value, but it is invalid in standard SQL.)

More DBMS and SQL questions

Exams that ask this topic