Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

calcaulate percentage for each column by its own total

$
0
0

i got data like this :

A	    B	           C
(35%)54	  (60%)9	 (37%) 63
(25%)39	  (26%)4	(25%) 43
(24%)37	  (13%)2	(23%) 39
(14%)22	   0	        (13%) 22
0	   0	           0 

the base data at start are only columns A and B.

what i want to do is

1) to calculate percent for column A (where the total to calculate will be the sum of A)

2) to do the same for B

3)column c is the sum of A+B, and then calculate the percent like in A.

can it be done in a single query, or i must use temp tables?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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