作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
I am using below query for fetching the record month wise but it give wrong data
SELECT
(count( server_time::timestamp::date)) ,
min(server_time::timestamp::date) as "Month Date"
FROM
complaint_details_v2
WHERE
server_time between '2018/08/01' and '2018/10/30'
GROUP BY
floor((server_time::timestamp::date - '2018/08/01'::date)/30)
ORDER BY
2 ASC
结果
Count Month Date
2774 2018-08-01
5893 2018-08-31
1193 2018-09-30
但是结果会是
Count Month Date
2774 2018-08-01
5893 2018-09-01
1193 2018-10-01
最佳答案
SELECT
count(*),
date_trunc('month', servertime)::date as month_date
FROM log
GROUP BY date_trunc('month', servertime)
ORDER BY 2
关于postgresql - 我如何在 postgresql 中的两个日期之间获取记录月份(按月份分组日期)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53114264/
我是一名优秀的程序员,十分优秀!