【发布时间】:2022-12-02 07:34:20
【问题描述】:
I'm trying to avoid writing twice the EXTRACT condition. There is any way to do that? Count over the previous alias apparently is not valid.
SELECT EXTRACT(DECADE FROM to_date(released_year::text, 'yyyy')) AS decade,
count(decade) AS total_by_decade
FROM album ...
【问题讨论】:
-
no you can avoid it, you can only make a cte
标签: sql postgresql