SELECT DISTINCT 範例 - Amazon Redshift

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

SELECT DISTINCT 範例

從 CATEGORY 資料表傳回不同類別群組的清單:

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

傳回 2008 年 12 月的不同週數集:

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)