关于小计合计,不使用GROUP BY 如何实现,我没有用会报错 SELECT Yname AS '分区名称',
o.PotocolNO AS '协议编号',
CASE WHEN GROUPING(BldName)=0 AND GROUPING(Yname)=1 THEN '小计' ELSE BldName END AS '楼栋名称',
RoomName AS '房间代码',
CstName AS '客户名称',
CardID1 AS '证件号码',
MobileTel1 AS '联系方式',
o.BldArea AS '建筑面积' ,
o.Price AS '单价',
r.HtTotal AS '合同总价',
o.PayformName AS '付款方式',
o.Earnest AS '应付定金',
(r.HtTotal-o.AjTotal-o.GjjTotal) AS '首付款(含定金)',
(o.GjjTotal+o.AjTotal) AS '贷款',
o.YwblDate AS '认购日期',
o.Ywy AS '置业顾问'
FROM dbo.rptvs_Xsd r
RIGHT JOIN dbo.es_Order o ON r.TradeGUID = o.TradeGUID
WHERE SaleType='认购'
AND ProjName = '翡翠绿洲-一期'
AND CONVERT(VARCHAR(100),o.YwblDate,23)>'2007-07-01' AND CONVERT(VARCHAR(100),o.YwblDate,23)<'2010-07-01'
ORDER BY bldname
WITH ROLLUP
上面是代码
下面是报错:
消息 319,级别 15,状态 1,第 23 行
关键字 'with' 附近有语法错误。如果此语句是公用表表达式、xmlnamespaces 子句或者更改跟踪上下文子句,那么前一个语句必须以分号结尾。
分享到:更多
------解决方案-------------------- 如果你不用group by,那么后面是不能有 with rollup的,否则就会报错的哈 ------解决方案-------------------- 哦 ,不用with rollup,就不能用grouping函数 ------解决方案--------------------