Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 按月计算的累计值总和_Sql_Sql Server 2008_Cumulative Sum - Fatal编程技术网

Sql 按月计算的累计值总和

Sql 按月计算的累计值总和,sql,sql-server-2008,cumulative-sum,Sql,Sql Server 2008,Cumulative Sum,我在SQL Server中执行查询时,发现一个错误 “order”附近的语法不正确 我已经看到了一些关于它的问题,并对代码进行了修订,但我看不出哪里出了问题 以下是查询: SELECT datepart(month, nota.DT_Sale_Forma_Bill_Exit) AS mon_text, sum(SUM(nota.NM_Material)) OVER (ORDER BY datepart(month,nota.DT_Sale_Forma_Bill_Exit))

我在SQL Server中执行查询时,发现一个错误

“order”附近的语法不正确

我已经看到了一些关于它的问题,并对代码进行了修订,但我看不出哪里出了问题

以下是查询:

SELECT  
    datepart(month, nota.DT_Sale_Forma_Bill_Exit) AS mon_text,
    sum(SUM(nota.NM_Material)) OVER (ORDER BY datepart(month,nota.DT_Sale_Forma_Bill_Exit)) 
FROM
    DW_DTS_Representative usuario
INNER JOIN 
    DIS_DTS_Invoice_Fact nota ON usuario.SK_Representative =  nota.SK_Representative
INNER JOIN
    DW_DTS_Operation_Nature cfop ON cfop.SK_Operation_Nature = nota.SK_Operation_Nature
INNER JOIN
    DW_DTS_Emitter cli ON cli.SK_Emitter = nota.SK_Emitter
WHERE
    nota.CD_Currency = '1'
    AND nota.CD_Site = '001'
    AND nota.DT_Sale_Forma_Bill_Exit = '2017'
    AND cli.CD_Customer_Group != '16'
GROUP BY 
    datepart(month, nota.DT_Sale_Forma_Bill_Exit)
ORDER BY 
    datepart(month, nota.DT_Sale_Forma_Bill_Exit)

直到SQLServer2012年才推出,但微软网站说,它的版本从2008年开始。over条款于2005年引入,但直到2012年才支持order by with aggregates。