久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

分區(qū)總和不起作用

Sum over partition not working(分區(qū)總和不起作用)
本文介紹了分區(qū)總和不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一些關于分區(qū)函數的代碼,但它不起作用.

I've got some code with the partition function, but it's not working.

我收到一條錯誤消息,內容為

I get an error message that says

'Sales' 附近的語法不正確

Incorrect syntax near 'Sales'

有人知道為什么嗎?看了其他分區(qū)問題,沒找到答案,

Does anyone know why? I looked at the other partition questions, didn't find an answer,

代碼(下面)應該從 Aggregated Sales History 表中選擇 PriceZoneID 和 Sales,然后使用 OVER 函數總結總銷售額,并將該數據放入名為 Total Sales 的新列中.

The code (below) is supposed to select PriceZoneID and Sales from the Aggregated Sales History table then sum up the total sales using the OVER function and put that data in a new column called Total Sales.

然后應該在名為 TotalSalesByZone 的新列中使用 OVER (PARTITION) 表達式總結每個區(qū)域的銷售額,然后按價格區(qū)域 ID 和銷售額對數據進行排序

It should then sum up the sales for each zone using the OVER (PARTITION) expression in a new column called TotalSalesByZone then order the data by Price Zone ID and Sales

Select PriceZoneID, 
    Sales,
SUM(Sales) OVER () AS Total Sales, 
SUM(Sales) OVER (PARTITION BY PriceZoneID) AS TotalSalesByZone
From AggregatedSalesHistory
ORDER BY PriceZoneID AND Sales; 

(Partition By 將結果劃分為 Partitions,例如 Zones)

(Partition By divides the result into Partitions eg Zones)

如果您能發(fā)布帶有正確答案的代碼,將不勝感激!

If you could post the code with the correct answer, it would be greatly appreciated!

推薦答案

現在退出評論,因為糾正那里的錯誤有點愚蠢.您的代碼中有 1 個印刷錯誤和 1 個語法錯誤:

Coming out of the comments now, as it's getting a little silly to correct the errors in there. There is 1 typograhical error in your code, and 1 syntax error:

Select PriceZoneID, 
       Sales,
       SUM(Sales) OVER () AS Total Sales, --There's a space in the alias
       SUM(Sales) OVER (PARTITION BY PriceZoneID) AS TotalSalesByZone
FROM AggregatedSalesHistory
ORDER BY PriceZoneID AND Sales; --AND is not valid in an ORDER BY clause

正確的查詢是:

Select PriceZoneID, 
       Sales,
       SUM(Sales) OVER () AS TotalSales, --Removed Space
       SUM(Sales) OVER (PARTITION BY PriceZoneID) AS TotalSalesByZone
FROM AggregatedSalesHistory
ORDER BY PriceZoneID, Sales; --Comma delimited

這篇關于分區(qū)總和不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應該使用什么 SQL Server 數據類型來存儲字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數據)
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
How to convert #39;2016-07-01 01:12:22 PM#39; to #39;2016-07-01 13:12:22#39; hour format?(如何將“2016-07-01 01:12:22 PM轉換為“2016-07-01 13:12:22小時格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應該返回“1?什么時候不能投射為日期?)
主站蜘蛛池模板: 日韩久久久久久 | 日日夜夜天天 | 国内自拍偷拍视频 | 亚洲男人天堂av | 久久在线看| 日韩欧美中文 | 国内自拍视频在线观看 | 中文字幕在线一区二区三区 | 久久婷婷麻豆国产91天堂 | 国产毛片久久久 | 噜啊噜在线 | 亚洲成人一区二区 | 狠狠综合久久av一区二区小说 | 午夜网| 国产精品一区一区 | 久久久精品视频免费 | 狠狠草视频 | avhd101在线成人播放 | 精品国产一二三区 | 日日日干干干 | 欧美激情精品久久久久 | 久久伊人精品一区二区三区 | 性视频一区 | 日韩在线中文字幕 | 性一交一乱一伦视频免费观看 | 亚洲男女视频在线观看 | 亚欧精品一区 | 国产精品久久久久国产a级 欧美日本韩国一区二区 | 看片国产 | 97精品国产一区二区三区 | 精品亚洲永久免费精品 | 日韩在线一区二区三区 | 成人精品一区亚洲午夜久久久 | 国产一区二区三区免费视频 | www.亚洲一区二区三区 | 日韩精品一区二区三区中文字幕 | 免费观看a级毛片在线播放 黄网站免费入口 | 日韩在线观看一区 | 欧美一区二区久久 | 91一区二区三区 | 天天草天天射 |