有人能告诉我导致此错误的原因吗?
在<g:each var="game" in="${games}">
<!-- Render game -->
<g:each var="category" in="${game.categories}">
<!-- Render the game's category -->
</g:each>
</g:each>
中,我收到错误错误的语法在&#39; order&#39; 附近。我已将错误隔离到SQLServer 2005
(当我在over子句中删除顺序时,错误就消失了)。我查看了文档并搜索了解决方案,但无法找到问题所在。
OVER clause
感谢您的帮助!!
答案 0 :(得分:2)
您不能将SUM
与OVER
和Partition by..Orderby
一起使用,仅与PARTITION BY
一起使用。订购你想要总结的东西是没有意义的。
SELECT bill.[cust_id],
Month(bill.[del_date]),
Year(bill.[del_date]),
Sum(Sum(Isnull(bill.[sum_count], 0)))
OVER (partition BY bill.[cust_id]) AS QtyProcessed
FROM envelopebilling bill
WHERE bill.[cust_id] = 1721
AND bill.[del_date] BETWEEN '5/1/2015' AND '10/31/2015'
GROUP BY bill.[cust_id],
Month(bill.[del_date]),
Year(bill.[del_date])
ORDER BY bill.[cust_id],
Year(bill.[del_date]),
Month(bill.[del_date])
答案 1 :(得分:2)
如果分区依据与组相同,则应该只能通过
删除分区SELECT bill.[cust_id] , MONTH(bill.[del_date]), YEAR(bill.[del_date]),
SUM(ISNULL(bill.[sum_count], 0)) AS QtyProcessed
FROM EnvelopeBilling bill
WHERE bill.[cust_id]= 1721
AND bill.[del_date] BETWEEN '5/1/2015' AND '10/31/2015'
GROUP BY bill.[cust_id], YEAR(bill.[del_date]), MONTH(bill.[del_date])
ORDER BY bill.[cust_id], YEAR(bill.[del_date]), MONTH(bill.[del_date])