Deviopath › PostgreSQL

One Contact List

Medium · Set Operations

UNION stacks the rows of two queries and removes duplicates (UNION ALL keeps them). Both queries must return the same number of columns.

Some emails are stored with capital letters, and some people are both a customer and a supplier. Return a single column email with every distinct email from customers and suppliers, converted to lowercase with lower(). Sort by email.

Next: Orders per Customer, Zeros Included