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
 Old Forums
 CLOSED - General SQL Server
 SUM two colums

Author  Topic 

kifeda
Posting Yak Master

136 Posts

Posted - 2005-08-08 : 18:19:07
How do I sum two columns? I have a column named TOTALHOURSWORKED and a column named TOTALHOURSWORKEDOT. I tried to sum them like:
select sum(totalhoursworked, totalhoursworkedot) as GrandTotal

But that that didn't work because SUM only likes one argument.

Any suggestions?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-08-08 : 18:23:21
select sum(totalhoursworked + totalhoursworkedot) as GrandTotal

Tara
Go to Top of Page

Nidal
Starting Member

3 Posts

Posted - 2006-03-10 : 11:03:15
quote:
Originally posted by tkizer

select sum(totalhoursworked + totalhoursworkedot) as GrandTotal

Tara

Go to Top of Page

Nidal
Starting Member

3 Posts

Posted - 2006-03-10 : 11:19:50
i hope this will be a solution for u

select sum(totalhoursworked + totalhoursworkedot)from <table name>;

or

select totalhoursworked,totalhoursworkedot,totalhoursworked + totalhoursworkedot from <table name>;

or

select totalhoursworked,totalhoursworkedot,totalhoursworked + totalhoursworkedot as "grandtotal" from <table name>;
or

or

select totalhoursworked+totalhoursworkedot from <tablename>;

or


select sum(totalhoursworked + totalhoursworkedot) as "GrandTotal" from <table name>;

Go to Top of Page
   

- Advertisement -