Foxtable(狐表)用户栏目专家坐堂 → [求助]最近专攻MSSQL,这条语句好有难度!


  共有4496人关注过本帖平板打印复制链接

主题:[求助]最近专攻MSSQL,这条语句好有难度!

帅哥哟,离线,有人找我吗?
jnletao
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:936 积分:7725 威望:0 精华:0 注册:2013/7/7 13:37:00
[求助]最近专攻MSSQL,这条语句好有难度!  发帖心情 Post By:2014/1/8 10:21:00 [只看该作者]

Create view [dbo].[vBillDetailMx] As select tgoods.typecode, tgoods.goodsbrand, tgoods.goodstype, tgoods.ifdiscount, tgoods.supply, tgoods.remark, billid, custname, billcode, tbill.adddate, addtime, mremark, fuser, maker, makerdate, editer, editdate, billtype, inorout, tbill.vipcode, paytype, skmoney, zlmoney, ysmoney, depotname, field1, field2, field3, field4, field5, DatePart(hh,tbill.addtime) as hjtime, (Year(tbill.adddate) + '-' + Month(tbill.adddate)) as hjmonth, DatePart(yyyy,tbill.adddate) as hjyear, DatePart(ww,tbill.adddate) as weekdate, '全部' as allbill, tbilldetail.billdetailid, (Case DatePart(q,tbill.adddate) When 1 Then DatePart(yyyy,tbill.adddate) +'年一季度' When 2 Then DatePart(yyyy,tbill.adddate)+'年二季度' When 3 Then DatePart(yyyy,tbill.adddate)+'年三季度' When 4 Then DatePart(yyyy,tbill.adddate)+'年四季度') End) as hjseason, tvip.vipname, tbilldetail.barcode, tbilldetail.dbillcode, tbilldetail.goodsstyle, tbilldetail.goodsname, tbilldetail.units, tbilldetail.sizegroup, tbilldetail.colorcode, tbilldetail.colorname, tbilldetail.colorvalue, tbilldetail.detailfield1, tbilldetail.detailfield2, tbilldetail.detailfield3, tbilldetail.detailfield4, tbilldetail.detailfield5, tbilldetail.sizecode, tbilldetail.sizename, tbilldetail.number as number1, tbilldetail.money as money1, tbilldetail.inmoney as inmoney1, (Case tbill.billtype When In ('销售出货','销售退货') Then tbilldetail.number*tbilldetail.sign*-1 Else tbilldetail.number*tbilldetail.sign End) as [number], tbilldetail.discount, tbilldetail.price, (Case tbill.billtype When In ('销售出货','销售退货') Then tbilldetail.money*tbilldetail.sign*-1 Else tbilldetail.money*tbilldetail.sign End) as [money], tbilldetail.colposition, tbilldetail.rowposition, tbilldetail.dremark, tbilldetail.sign, tbilldetail.inprice, (Case tbill.billtype When In ('销售出货','销售退货') Then tbilldetail.inprice*tbilldetail.number*tbilldetail.sign*-1 Else tbilldetail.inprice*tbilldetail.number*tbilldetail.sign End) as inmoney, tgoods.dpprice, tgoods.xsprice, tgoods.goodsseason, tgoods.depotup, tgoods.depotdown from (tbill left join (tbilldetail left join tgoods on tbilldetail.goodsstyle=tgoods.goodsstyle) on tbill.billcode=tbilldetail.dbillcode) left join tvip on tbill.vipcode=tvip.vipcode 

 回到顶部
总数 12 1 2 下一页