Questions / Quant development, SQL & data pipelines

COUNT and NULL

Foundation, about 6 minutes. Question D033.

A SQL table has four rows. Column x contains 7, NULL, 9, NULL. What does COUNT(x) return?

Answer it in the app It's free. You get hints, a second try if you miss, and a follow-up question.

Show the answer and worked solution

Answer: 2 count

  1. COUNT(x) counts non-null values of x, so it returns 2.

Interview shortcut. COUNT(col) skips NULLs.

In the app this has a follow-up where one thing about the setup changes. Try the follow-up.

More sql & data pipelines questions