How many groups does GROUP BY create for a column containing multiple NULL values?
The query combines values of x from iv_t1 and iv_t2 using UNION ALL, then groups the results. Which groups will it produce, and what will their counts be?
Predict the resultNULLMiddleAnalystData EngineerBackendQA
Input data · iv_t1
| x |
|---|
| 1 |
| 1 |
| 2 |
| NULL |
Input data · iv_t2
| x |
|---|
| 1 |
| 2 |
| 2 |
| 3 |
| NULL |
Query
SELECT x, COUNT(*) AS cnt_rows, COUNT(x) AS cnt_x
FROM (
SELECT x FROM iv_t1
UNION ALL
SELECT x FROM iv_t2
) t
GROUP BY x
ORDER BY cnt_rows DESC, x