partition by sql server

Solutions on MaxInterview for partition by sql server by the best coders in the world

showing results for - "partition by sql server"
Cristina
14 Jan 2016
1-- When using an aggregation function (SUM, COUNT, RANK, etc...)
2-- Creates a specification on which you need to perform that agreggation
3-- Example:
4SELECT Customercity, 
5       SUM(Orderamount) OVER(PARTITION BY Customercity) AS SumOrderAmount
6-- performs avg amount when and only when you see a customer city
7-- Orderamount | Customercity --(Comment added)-- | SumOrderAmount
8-- 100	| Chicago "partition1" | 250
9-- 150  | Chigago "partition1" | 250
10-- 50   | Houston "partition2" | 75
11-- 25   | Houston "partition2" | 75