Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

SELECT DISTINCT Examples

Return a list of different category groups from the CATEGORY table:

Copy
select distinct catgroup from category order by 1; catgroup ---------- Concerts Shows Sports (3 rows)

Return the distinct set of week numbers for December 2008:

Copy
select distinct week, month, year from date where month='DEC' and year=2008 order by 1, 2, 3; week | month | year -----+-------+------ 49 | DEC | 2008 50 | DEC | 2008 51 | DEC | 2008 52 | DEC | 2008 53 | DEC | 2008 (5 rows)