0
0
PostgreSQLquery~10 mins

IS DISTINCT FROM for NULL-safe comparison in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select rows where column_a is distinct from column_b, including NULL-safe comparison.

PostgreSQL
SELECT * FROM table_name WHERE column_a [1] column_b;
Drag options to blanks, or click blank then click option'
AIS NOT NULL
B=
C!=
DIS DISTINCT FROM
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' operator which returns NULL when comparing with NULL values.
Using '!=' which does not handle NULLs properly.
2fill in blank
medium

Complete the code to select rows where column_a is NOT distinct from column_b, including NULL-safe comparison.

PostgreSQL
SELECT * FROM table_name WHERE column_a [1] column_b;
Drag options to blanks, or click blank then click option'
AIS NOT DISTINCT FROM
BIS DISTINCT FROM
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which returns NULL when comparing NULLs.
Using '!=' which does not handle NULLs properly.
3fill in blank
hard

Fix the error in the WHERE clause to correctly compare column_a and column_b with NULL-safe comparison.

PostgreSQL
SELECT * FROM table_name WHERE column_a [1] column_b;
Drag options to blanks, or click blank then click option'
A=
B!=
CIS DISTINCT FROM
DIS NOT NULL
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving '=' which causes NULL comparison issues.
Using '!=' which does not handle NULLs correctly.
4fill in blank
hard

Fill both blanks to select rows where column_x is distinct from column_y and column_z is NOT distinct from column_w.

PostgreSQL
SELECT * FROM table_name WHERE column_x [1] column_y AND column_z [2] column_w;
Drag options to blanks, or click blank then click option'
AIS DISTINCT FROM
B=
CIS NOT DISTINCT FROM
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' or '!=' which do not handle NULLs properly.
Mixing up IS DISTINCT FROM and IS NOT DISTINCT FROM.
5fill in blank
hard

Fill all three blanks to select rows where column_a is distinct from column_b, column_c is NOT distinct from column_d, and column_e is distinct from NULL.

PostgreSQL
SELECT * FROM table_name WHERE column_a [1] column_b AND column_c [2] column_d AND column_e [3] NULL;
Drag options to blanks, or click blank then click option'
AIS DISTINCT FROM
BIS NOT DISTINCT FROM
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' to compare with NULL which returns NULL instead of true/false.
Confusing IS DISTINCT FROM and IS NOT DISTINCT FROM.