所以我在postgres中有这样的查询
select a,b,c,d from table a where date between '2020-01-01' and '2021-01-01'
union all
select a,b,c,d from table b where date between '2020-01-01' and '2021-01-01'
union all
select a,b,c,d from table c where date between '2020-01-01' and '2021-01-01'
如何用日期声明 i 参数,以便我只需填写一次?
像这样的东西
declare d1 as date, d2 as date
set d1 as '2020-01-01'
set d2 as '2021-01-01'
select a,b,c,d from table1 a where date between d1 and d2
union all
select a,b,c,d from table2 a where date between d1 and d2
union all
select a,b,c,d from table3 a where date between d1 and d2