SQL DISTINCT
The DISTINCT command finds all unique values in a given column.
-- Works in PostgreSQL, MySQL, SQL Server, and Oracle
SELECT
distinct dollar_amount
FROM
rent_payments;
rent_payments table
| building_id | payment_date | dollar_amount |
|---|---|---|
| 1 | 3/1/2018 | 2000 |
| 1 | 3/2/2018 | 1500 |
| 2 | 3/1/2018 | 1800 |
| 2 | 3/3/2018 | 1900 |
| 1 | 4/2/2018 | 2000 |
| 1 | 4/2/2018 | 1500 |
| 2 | 4/1/2018 | 1800 |
| 2 | 4/2/2018 | 1900 |
Query results
| dollar_amount |
|---|
| 2000 |
| 1500 |
| 1800 |
| 1900 |