需求,成功状态为1,失败状态为0,现在统计18号的成订单多少次,失败订单多少次?
select BRAND_ID,STORE_ID
,sum(case when ORDER_STATUS = 1 then 1 else 1 end) as 成功
,sum(case when ORDER_STATUS = 0 then 0 else 1 end) as 失败
from t_loreal_product_order t
where CREATE_TIME >='2020-01-18 00:00:00' and CREATE_TIME <='2020-01-18 23:59:59'
group by BRAND_ID,STORE_ID