PostgreSQL日期间隔比较

时间:2019-06-20 07:48:04

标签: postgresql

我正在计算最近30天总订单与最近60天总订单之间的差额

 select count(s1.order_id) 
 from sales_sale s1
 full outer join sales_saleitem s2 on s2.order_id=s1.id
 WHERE (s1.date_created > current_date - interval '60' day) - (s1.date_created > current_date - interval '30' day )

0 个答案:

没有答案