NULL & three-valued logic
Exercise · SQL & Querying

Predict, then run it

Predict the output

a(k) = 1, NULL. b(k) = 1, NULL. Match rows treating NULL as equal to NULL:

SELECT a.k FROM a JOIN b ON a.k IS NOT DISTINCT FROM b.k ORDER BY a.k NULLS LAST;

Predict the exact output.