我有一个这样的表(表1)(我简化了它)
code | description | season
----------+------------------+--------------
500 | info 1 | fall
500 | info 4 | fall
500 | info 8 | fall
500 | info 1 | winter
300 | info 1 | spring
400 | info 1 | fall
我想要一个如下的表格,在那里我有每个季节的代码频率
season | Number of Unique Codes
----------+------------------------
fall | 2
winter | 1
spring | 1
到目前为止,我有:
SELECT
season,
count(DISTINCT code) AS "Number of Unique Codes"
FROM table_1
WHERE code IS NOT NULL
GROUP BY season
ORDER BY code desc;
然而,我遇到了一些问题。
1条答案
按热度按时间wn9m85ua1#
你的错误在
ORDER BY
,更改您的ORDER BY
按创建的别名排序。