🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: SQL Interview Queries: all 10 questions

Quiz: SQL Interview Queries · Question 10 of 10

Why is joined = '2022-01-01' AND joined < '2024-01-01' preferred over YEAR(joined) IN (2022, 2023)?

Why is joined >= '2022-01-01' AND joined < '2024-01-01' preferred over YEAR(joined) IN (2022, 2023)?

  1. A.It returns different rows
  2. B.The bare column can use an index on joined; a function on the column usually cannot
  3. C.YEAR() does not exist in any database
  4. D.Dates cannot be compared with >=
Answer & explanation

Correct answer: The bare column can use an index on joined; a function on the column usually cannot

Keeping the indexed column untouched keeps the query index-friendly.

Can you get the rest right without peeking?

Take the timed Quiz: SQL Interview Queries quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →