What remains after applying UNION DISTINCT to two tables?
Two tables contain repeated numbers. The query combines their results using UNION DISTINCT, removes NULL values, and sorts the remaining rows. Which numbers will it return?
Predict the resultDuplicates and top NJuniorAnalystData EngineerBackendQA
Input data · iv_t1
| x |
|---|
| 1 |
| 1 |
| 2 |
| NULL |
Input data · iv_t2
| x |
|---|
| 1 |
| 2 |
| 2 |
| 3 |
| NULL |
Query
SELECT x
FROM (
SELECT x FROM iv_t1 WHERE x IS NOT NULL
UNION DISTINCT
SELECT x FROM iv_t2 WHERE x IS NOT NULL
) AS merged
ORDER BY x