📜  按 sql server 分区 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:26.139000             🧑  作者: Mango

代码示例1
-- When using an aggregation function (SUM, COUNT, RANK, etc...)
-- Creates a specification on which you need to perform that agreggation
-- Example:
SELECT Customercity, 
       SUM(Orderamount) OVER(PARTITION BY Customercity) AS SumOrderAmount
-- performs avg amount when and only when you see a customer city
-- Orderamount | Customercity --(Comment added)-- | SumOrderAmount
-- 100    | Chicago "partition1" | 250
-- 150  | Chigago "partition1" | 250
-- 50   | Houston "partition2" | 75
-- 25   | Houston "partition2" | 75