我想计算一段时间内(比如整月),每位售货员,12:00到15:00,苹果的销量。
但以下语法只能计算:每天,每位售货员,12:00到15:00,苹果的销量。
select
date, job_id,
count(distinct case when substr(order_time,12,2) between 12 and 15 then ord_id end) as apple_order
from
A
where
date >='${startdate}' and date<='${enddate}' and type='apple'
group by
job_id,date
全部评论
(3) 回帖