Boolean Expressions in SELECT Clause

A boolean expression is a logical statement that returns either true or false.

A boolean expression in SELECT follows this syntax: SELECT {boolean_expression} as {alias}.

This example demonstrates a query that satisfies one numerical logical condition.

1SELECT Profit > 0 as Profits FROM "Superstore" LIMIT 5;
Profits
true
true
true
false
true

This example demonstrates a query that satisfies two numerical logical conditions.

1SELECT Profit > 0 and Profit < 100 as Profits FROM "Superstore" LIMIT 5;
Profits
true
false
true
false
true

This example demonstrates a text comparison.

1SELECT Customer_Name LIKE 'A%' as "A Names" FROM "Superstore" LIMIT 5;
A Names
false
false
false
false
true