gpt4 book ai didi

PostgreSQL order by month name on distinction

转载 作者:行者123 更新时间:2023-11-29 13:43:51 25 4
gpt4 key购买 nike

我有这个问题

SELECT DISTINCT ON (tours.departure.departure_month)
tours.departure.departure_month
FROM tours.departure

但我想按月份名称对不同的月份进行排序。我已经从类似的问题 to_date(tours.departure.departure_month, 'Month') 中试过了,但我无法让它与 DISTINCT ON 一起工作。

最佳答案

departure_month 的列类型是什么,是日期还是月份名称,如果是日期类型的列可以尝试以下操作:

SELECT DISTINCT ON (tours.departure.departure_month)
tours.departure.departure_month
FROM tours.departure
ORDER BY month(tours.departure.departure_month) DESC;

关于PostgreSQL order by month name on distinction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51477788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com