0
我的表是這樣的Postgres的,請注意,所有的日子由01開始,只有1項在一個月+一年在一年之內的日期查詢
SELECT * FROM "fis_historico_receita"
+----+------------+---------------+
| id | data | receita_bruta |
+----+------------+---------------+
| 1 | 2010-02-01 | 100000.0 |
| 2 | 2010-01-01 | 100000.0 |
| 3 | 2009-12-01 | 100000.0 |
| 4 | 2009-11-01 | 100000.0 |
| 5 | 2009-10-01 | 100000.0 |
| 6 | 2009-09-01 | 100000.0 |
| 7 | 2009-08-01 | 100000.0 |
| 8 | 2009-07-01 | 100000.0 |
| 9 | 2009-06-01 | 100000.0 |
| 10 | 2009-05-01 | 100000.0 |
| 11 | 2009-04-01 | 100000.0 |
| 12 | 2009-03-01 | 100000.0 |
| 13 | 2009-02-01 | 100000.0 |
| 14 | 2009-01-01 | 100000.0 |
| 15 | 2008-12-01 | 100000.0 |
+----+------------+---------------+
我想要的是找到12個月從現在開始。
我嘗試這樣做:
select *
from fis_historico_receita
where data in interval '1 year'
我真的想使用間隔一個答案,+1去給大家上的Postgres運行
爲了得到12個月我做了:... BETWEEN(NOW() - 間隔'1年' - 間隔'1個月')AND ...仍然接受指向ver是的 – 2010-03-22 20:40:39