SELECT DISTINCT collapses duplicate projected rows.
DISTINCT is opt-in
SELECT DISTINCT asks SQL to collapse duplicate projected rows. Without that word, the bag remains a bag. Note: deduplication is explicit in this book.
distinct is explicit
DISTINCT collapses the bag
Plain projection had row count 5, while DISTINCT recomputes row count 2. Note: the render shows the deduplicated result.
plain=5,distinct=2
SQL bag/multiset + three-valued NULL logic, deterministic but surprising; tiny finite tables; no engine/perf claims. Set algebra is Book 1.
The same opt-in applies to identifiers
Plain sid projection recomputes to row count 5, while DISTINCT sid recomputes to row count 3. Note: DISTINCT collapses equal projected rows after projection.
plain sid=5,distinct sid=3
SQL bag/multiset + three-valued NULL logic, deterministic but surprising; tiny finite tables; no engine/perf claims. Set algebra is Book 1.
Summary
DISTINCT is the set-like escape hatch inside bag SQL. Note: bag multiplicity and NULL behavior are here; pure set algebra was Book One.
distinct summary