SQL Boolean Data Type

Actually three-valued, not two — TRUE, FALSE, and NULL are all valid states.

What & Why

A BOOLEAN column holds TRUE or FALSE — but like every column type, it can also hold NULL, meaning "unknown" rather than either value. This is genuinely three-valued logic, not simple binary.

See How It Works

BOOLEAN RESULT — product.feedback
iduser_idnps_scoreis_promoter
11019TRUE
2102NULLNULL
31037FALSE
4104NULLNULL

The comparison `nps_score >= 8` produces a Boolean value: `TRUE` for 9, `FALSE` for 7, and `NULL` when the score itself is unknown.

EXAMPLE QUERY
SELECT id, user_id, nps_score,
  nps_score >= 8 AS is_promoter
FROM product.feedback;
Now You Try

Practice this concept

Product wants each feedback score classified as promoter, not promoter, or unknown when the NPS score is missing.

Available schema
product

Prefix tables with product.table_name.

iduser_idnps_scoreis_promoter
product.feedback
ColumnType
idinteger
user_idinteger
feature_idinteger
ratinginteger
nps_scoreinteger
commenttext
created_attimestamp with time zone
moderation_buckettext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario