34,588
社区成员
发帖
与我相关
我的任务
分享
select convert(varchar(100),[saledate],112) ,COUNT(distinct saleid), SUM(subsale), SUM(subsale)/COUNT(distinct saleid)
,sum(case when warehouseid between '010102' and '010103' then subsale else 0 end)
,count(distinct case when warehouseid between '010102' and '010103' then saleid end)
FROM sd201601
where saledate between '20160101 00:00:00' and '20160109 23:59:59'
group by convert(varchar(100),[saledate],112) order by convert(varchar(100),[saledate],112) DESC