在Mysql中使用变量
在Mysql中使用变量
set @num = 1;
select STOREID,CONTACTPHONE,count(*) ARRIVALNUM,CURRENT_DATE -@num COUNTDATE from cater_order_fact
where
CONTACTPHONE
in (
select CONTACTPHONE from crm_dw.cater_order_fact where DATEDIFF(now(),DINNINGTIME) = @num
)
AND DINNINGTIME > date_sub(CURRENT_DATE -@num ,interval 3 month)
group by CONTACTPHONE,STOREID
SpagoBI中文社区,致力于国际优秀开源BI套件SpagoBI在中国的普通推广;
联系我们QQ群:275725345