Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Row Total

Author  Topic 

BigRetina
Posting Yak Master

144 Posts

Posted - 2003-07-10 : 07:08:17
Salute..
How can I display a row total in a column??
for example
a select query returns the following rowset

AccountNo Balance1 Balance2 Balance3 Total
--------- -------- -------- -------- -----
1 100 200 300 600
5 150 150 0 300

How can I calculate Total???
Thanks!!!


robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-07-10 : 07:26:03
Balance1 + Balance2 + Balance3?

Unless this is a trick question...

Go to Top of Page

BigRetina
Posting Yak Master

144 Posts

Posted - 2003-07-10 : 10:05:16
Sorry!
I should have made it clear that Balance1, Balance2 are aggregates!!
Balance1 is just an alias!!
Sorry Again!

Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2003-07-10 : 10:09:24
That really doesn't make a difference...

create table #moo (thing int null, thing2 int null)
insert into #moo values (1,2)
insert into #moo values (3,4)
select thing, thing2 from #moo
select sum (thing), sum(thing2), sum (thing) + sum(thing2) from #moo
drop table #moo

-------
Moo. :)
Go to Top of Page
   

- Advertisement -