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

Total and percentage in the same row

$
0
0

Hi guys, sorry for suach a stupid question but I'm loosing all my skill trying to understand a discrepancy between two big table ( 100 millions rows, one table SQL 2008 and the other Oracle...funny). Anyway:

Code Period  CodeCl  Client   Tot

1014 201012 73340 Singapore 644.26 
1014 201012 68446 New York 75.54 

Create table Airport ( code int, period varchar (10), codecl int, client varchar (30), tot dec (10,2))

insert into airport values (1014, 201012, 73340, Singapore, 644.26 ), (1014, 201012, 68446, New York, 75.54)

I need the easiest solution to achieve this result:

1014 201012 73340 Singapore 644.26  719.8  89.505
1014 201012 68446 New York 75.54  719.8  10.495

where 719.8 is the total client per period (usually I got 1 Client 1 period but sometime the airlines change slot...) and 89.505 is the % of Singapore in the total and 10.495 is the % of New York in the total.

That's why I'm gonna to expect a cost that I need to split...

And I need to find the discrepancy but this is another stuff...

Thanks

 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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