【发布时间】:2021-09-14 15:53:52
【问题描述】:
我关注了这个帖子Order by using month name in PostgreSQL,但没有成功!
我有一个查询(它的工作),我只需要按 mont 名称对结果进行排序。这是我正在使用的查询:
select to_char(purchase_date, 'Month') as mes_2021,
sum(gmv::float4) as soma_gmv
from tablename
where purchase_date > '2021-01-01'
GROUP BY mes_2021
我正在尝试:
order by to_date(purchase_date, 'Month') - No success
order by date_part(purchase_date::date, 'Month') - No success
如果我使用order by mes_2021
【问题讨论】:
-
您的代码有什么原因不包括 1 月 1 日吗?
-
不确定我是否理解,但一月份就在那里,对吧?哦,现在我看到 '>' 而不是 '>=' 谢谢
-
。 .
purchase_date > '2021-01-01'.
标签: sql postgresql