我想运行像
这样的查询SELECT distinct( generate_series(timestamp start_date, interval '1' day) as d
FROM NAEDO
WHERE start_date >= '2014/08/13'
AND start_date <= '2014/09/12'
ORDER BY start_date
并返回如下数据:(范围内的天数,但来自数据[可能连续几天])
days
---
13
16
17
18
25
29
1
3
答案 0 :(得分:0)
这是你在找什么?
SELECT distinct date_trunc('day', start_date) as d
FROM NAEDO
WHERE start_date >= '2014-08-13' AND start_date <= '2014-09-12'
ORDER BY d
答案 1 :(得分:0)
SELECT DISTINCT start_date, extract(day from start_date) as d
FROM NAEDO
WHERE start_date >= '2014-08-13' AND start_date <= '2014-09-12'
ORDER BY start_date
如果没有额外的列,也许还有办法可以做到这一点...... 但这是针对报告的,您可以省略报告中的额外列。