Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

SUM DISTINCT OVER PATITION

$
0
0

hello,

I have and income aggregated table..

which have families repeated for multiple income sources... i want to find sum of that income over total families not repeated...

eg

NATIONALITYINCOME TYPEVALUETOTAL FAMILIES
11100020
12200020
13300020
21150010
22110010
(1000+2000+3000)/20   for nat 1

(1500+1100)/10 for nat 2

and 

(1000+2000+3000+1500+1100)/(10+20)
 for total

can you help with query to calculate that...

I did it using (with and select distinct)... but can i do it without them.. with only (join,distinct and over)


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>