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

分區總和不起作用

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

問題描述

限時送ChatGPT賬號..

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

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'

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

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) 表達式總結每個區域的銷售額,然后按價格區域 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)

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

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

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

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

相關文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應該使用什么 SQL Server 數據類型來存儲字節 [])
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?什么時候不能投射為日期?)
主站蜘蛛池模板: 亚洲毛片在线 | 国户精品久久久久久久久久久不卡 | 一级黄色毛片免费 | 久久噜噜噜精品国产亚洲综合 | 久久激情网 | 欧美成人在线影院 | 国产精品视频免费看 | 国产亚洲一区二区在线观看 | 91av在线视频观看 | 国产免费福利在线 | 91精品综合久久久久久五月天 | 欧美在线观看黄色 | 国产成人福利 | 超碰成人免费观看 | 久热精品在线观看视频 | 日韩精品一区二区三区在线观看 | 欧美一区二区三区 | 一区在线播放 | 亚洲成人福利视频 | 欧美极品视频 | 成年女人免费v片 | 欧美日韩视频在线播放 | 色综合天天天天做夜夜夜夜做 | 97成人在线 | 深夜福利影院 | 国产99热精品 | 亚洲国产一区二区三区, | 国产精品久久午夜夜伦鲁鲁 | 黄色a视频 | 亚洲精品久久久久久久久久久久久 | 国产精品久久久久久久久 | 国产高清免费 | 欧美日日 | sese视频在线观看 | 日韩有码在线播放 | 日本福利一区 | 一区二区三区视频在线观看 | 国产精品久久久久9999鸭 | 国产精品久久久久久久免费大片 | 人干人操 | av先锋资源|