标题:语句提示错误
只看楼主
yclm
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2022-1-22
 问题点数:0 回复次数:0 
语句提示错误
ALTER PROC [dbo].[proc_XSth]
  @GSCODE varchar(20)='A002',
 @where varchar(6000)='1=1'
as
 declare @sqlcmd varchar(8000)
if @where='1=1' set @where = 'year(ckdate)=year(getdate()) and month(ckdate)=month(getdate())'
  set @sqlcmd ='
  select * from (
select WRITEDATE,ckdate,GUESTNAME,paydate,CKPAPER,PCODE,PNAME,PSIZE,PFACTORY,CKAMOUNT,XSPRICE,销售总金额=CKAMOUNT*XSPRICE,TXSPRICE,实售总金额=CKAMOUNT*TXSPRICE,COSTPRICE,  TCOSTPRICE,   KCPOSI, KCDEPOT, KCAMOUNT,  OPERATOR, PAYTYPE
from [dbo].[v_pjck] where ckamount<0  AND GSCODE=''A002'' AND '+@where+'
union all
select '''','''','''','''','''','''','''','''',''合计:'',sum(CKAMOUNT),''0'' , sum(CKAMOUNT*XSPRICE),           ''0'', sum(CKAMOUNT*tXSPRICE),   sum(COSTPRICE),SUM(TCOSTPRICE),'''' ,''''  ,sum(KCAMOUNT), '''',    ''''
from [dbo].[v_pjck] where GSCODE=''A002'' AND '+@where+') t
'

 print (@sqlcmd)
 exec (@sqlcmd)
 


    select *  from (
 select ckdate,a.ckpaper,guestname,operator,incharge,paytype,paydate,fptype,a.fhmode,pcode,pname,psize,pfactory,ckamount,COSTPRICE,TCOSTPRICE,xsprice,sumxsprice=ckamount*xsprice*(100-yhl)/100,txsprice,sumtxsprice=ckamount*txsprice*(100-yhl)/100,CKAMOUNT*costprice,CKAMOUNT*tcostprice,xsml=ckamount*(xsprice*(100-yhl)/100*((100-fppoint)/100)-costprice),txsml=ckamount*(txsprice*(100-yhl)/100*((100-fppoint)/100)-costprice),kcdepot,kcposi,pjid,b.writedate
 from pj_ckls a left join pj_cklssub b on a.ckpaper=b.ckpaper where A.gscode='A001' AND guestname LIKE '%开思%' and year(ckdate)=year(getdate()) and month(ckdate)=month(getdate())
 union all
 select '','','','','','','','','','','','','合计:',sum(ckamount),sum(ckamount*COSTPRICE),sum(ckamount*TCOSTPRICE),'0',sum(ckamount*xsprice*(100-yhl)/100),'0',sum(ckamount*txsprice*(100-yhl)/100),'0','0',sum(ckamount*(xsprice*(100-yhl)/100*((100-fppoint)/100)-costprice)),sum(ckamount*(txsprice*(100-yhl)/100*((100-fppoint)/100)-costprice)),'','','',''
 from pj_ckls a left join pj_cklssub b on a.ckpaper=b.ckpaper where A.gscode='A001' AND guestname LIKE '%开思%'and year(ckdate)=year(getdate()) and month(ckdate)=month(getdate())) as t
   
消息 8155,级别 16,状态 2,第 7 行
没有为 't' 的列 21 指定任何列名称。
消息 8155,级别 16,状态 2,第 7 行
没有为 't' 的列 22 指定任何列名称。
搜索更多相关主题的帖子: year where sum and from 
2022-01-22 19:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-508216-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.057091 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved