我想运行像
这样的查询select ... as days where `date` is between '2010-01-28' and '2010-02-03'
并返回如下数据:
days
---
28
29
30
31
1
2
3
答案 0 :(得分:2)
select extract(day from d) as days
from generate_series(timestamp '2010-01-28', timestamp '2010-02-03', interval '1' day) as d
order by d;
SQLFiddle示例:http://sqlfiddle.com/#!15/d41d8/3464