🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: GROUP BY and HAVING: all 10 questions

Quiz: GROUP BY and HAVING · Question 9 of 10

Why does SELECT salary 12 AS yearly FROM employees WHERE yearly 600000 fail in standard SQL?

Why does SELECT salary * 12 AS yearly FROM employees WHERE yearly > 600000 fail in standard SQL?

  1. A.WHERE runs before SELECT, so the alias yearly does not exist yet
  2. B.Aliases are never allowed in SQL
  3. C.Multiplication is not allowed in SELECT
  4. D.WHERE must come after ORDER BY
Answer & explanation

Correct answer: WHERE runs before SELECT, so the alias yearly does not exist yet

Repeat the expression in WHERE, or use the alias only in ORDER BY.

Can you get the rest right without peeking?

Take the timed Quiz: GROUP BY and HAVING quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →