sql语句

                            
分不多还请大家多帮忙:   
  select   b.cname   as   包间名称,c.rankname   as   包间类型,a.cubegindate+a.cubegintime   as   开始时间,   a.cuenddate+a.cuendtime   as   结束时间,    
        a.drinkmoney   as   酒水消费,a.Othermoney   as   其他消费,a.cuzk   as   打折率,a.theorypayment   as   应付金额,a.factpayment   as   实收金额,    
          a.ywname   as   业务,a.cusname   as   客户,a.cuid   as   cuid   from     compartmentuse   a,   compartmentlist   b,   ranks   c    
        where(a.cid=b.cid)and(b.rankid=c.rankid)and(a.iftry=0)and(a.cuifnot=1)  
    union   all   select   '总计:'   as   包间名称,''   as   包间类型,null   as   开始时间,   null   as   结束时间,    
          sum(a.drinkmoney)   as   酒水消费,sum(a.Othermoney)   as   其他消费,null   as   打折率,sum(a.theorypayment)   as   应付金额,sum(a.factpayment)   as   实收金额,    
          ''   as   业务,''   as   客户,''   as   cuid     from     compartmentuse   a,   compartmentlist   b,   ranks   c      
    union     select   '优惠卷总额','',null   as   开始时间,null   as   结束时间,0,0,null   as   打折率,0,sum(a.cuprepaymoney1)   as   实收金额,'','',''   as   cuid  
            from   compartmentuse   as   a   ,   compartmentlist   as   b,   ranks   as   c  
    where(a.cid=b.cid)and(b.rankid=c.rankid)and(a.iftry=0)and(a.cuifnot=1)  
   
  这个语句我在‘查询分析器’中执行是没有问题的,可到deliph中却提示说(第一行‘.’附近有语法错误),但是当去掉第二个‘union’子句则可正确运行,看样子是第二个union子句出问题了,请大家多给些建议。。  
  在线等待。。。。。

查看回复