|
|
#2
kw8682016-08-21 01:43
下面是我的查询语句
求助:请大侠帮我把下面的查询语句改写为可以在SQL"作业"中定时执行导出查询结果到EXCEL的语句,导出目录为D:\每个品牌每个区域.XLS
select e.zipcode,f.name_short,convert(char(6),a.time_conf,112) as ymth,c.classid,c.name_class,count(
distinct a.custid ) as 客户数,count(distinct b.shopid) as SKU数,
sum(b.value_ok) as [成交额],sum
(b.num_in / d.num_box) as [成交件数]
from t_bp_wsalebrk_h a with(nolock),
t_bp_wsalebrk_d b with(nolock) ,
t_bp_class c with(nolock),
t_bp_shop d with(nolock),
t_bp_cust e with(nolock),
t_bp_wsalewrkgroup f with(nolock)
where a.bill = b.bill and b.shopid = d.shopid and e.zipcode=f.groupid and
left(d.classid,len(c.classid)) = c.classid and a.flag_conf = '1' and a.custid = e.custid
and a.time_conf >= '2010-01-01' and a.time_conf < '当天日期’ --修改起止时间
and c.classid like '0%' and c.remark like '%基本%'
group by e.zipcode,f.name_short,convert(char(6),a.time_conf,112),c.classid,c.name_class
order by e.zipcode,c.classid
|