Description:
How many orders are not heavy? The query says 0. There are 5346.
The CASE labelled the orders with freight over 50 as heavy — and had no ELSE. So every other order got NULL. A filter on "not equal to heavy" asks a question about NULL, the answer is unknown, and all 5346 rows are dropped.
CASE WHEN "Freight" over 50 THEN 'heavy' ELSE 'standard' END
One line. 5346 come back. Every row gets a label.
▶ The full lesson is free, written out and hands-on, with runnable exercises that go green when you get them right: https://datapallas.com/academy/learn-sql/case-expressions
⚙ Set up in a few minutes — Northwind Company, PostgreSQL and CloudBeaver, all bundled: https://datapallas.com/learn-data
⭐ DataZeus — the open-source home of every course here. A star helps the next person find it: https://github.com/flowkraft/datazeus
#sql #sqltutorial #learnsql
Share this link via
Or copy link























