Sum of column value using PARTITION BY cluase

CGN007
Posted by CGN007 under Sql Server category on | Points: 40 | Views : 989
id name total
-----------------------
100 Raj 200
101 Ram 300
100 Raj 500
101 Ram 100
101 Raj 200


SELECT DISTINCT id,name,
SUM(amount) OVER (PARTITION BY name) AS Total FROM hm



Result
*******
id name total
-----------------------
100 Raj 900
101 Ram 400

Comments or Responses

Login to post response