Can anyone tell me what's causing this error? In SQL Server 2005, I am getting the error "Incorrect syntax near 'order'". I have isolated the error to the OVER clause (the error goes away when I remove the order by in the over clause). I have reviewed the documentation and searched for a solution but can't find what the problem is.
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]
ORDER BY YEAR(bill.[del_date]), MONTH(bill.[del_date])) 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])
Thanks for your help!!
Aucun commentaire:
Enregistrer un commentaire