我可以: 邀请好友来看>>
ZOL论坛 > 技术论坛 > SQL Server论坛 > 求助:请大侠帮我写这个定时导出查询结果到EXCEL的语句
帖子很冷清,卤煮很失落!求安慰
返回列表
签到
手机签到经验翻倍!
快来扫一扫!

求助:请大侠帮我写这个定时导出查询结果到EXCEL的语句

61浏览 / 0回复

kw868

kw868

0
精华
2
帖子

等  级:Lv.1
经  验:58
  • Z金豆: 0

    千万礼品等你来兑哦~快点击这里兑换吧~

  • 城  市:
  • 注  册:2008-04-30
  • 登  录:2017-04-23
发表于 2016-08-21 01:38:21
电梯直达 确定
楼主

求助:请大侠帮我写这个定时导出查询结果到EXCEL的语句

请大侠帮我把下面查询语句改写为可以做到SQL“作业”中定时执行的语句!



--查询区域FCS+总件数语句 查询完输出到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


高级模式
论坛精选大家都在看24小时热帖7天热帖大家都在问最新回答

针对ZOL论坛您有任何使用问题和建议 您可以 联系论坛管理员查看帮助  或  给我提意见

快捷回复 APP下载 返回列表