SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 SUM two colums
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kifeda
Posting Yak Master

136 Posts

Posted - 08/08/2005 :  18:19:07  Show Profile
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

USA
35954 Posts

Posted - 08/08/2005 :  18:23:21  Show Profile  Visit tkizer's Homepage
select sum(totalhoursworked + totalhoursworkedot) as GrandTotal

Tara
Go to Top of Page

Nidal
Starting Member

India
3 Posts

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

select sum(totalhoursworked + totalhoursworkedot) as GrandTotal

Tara

Go to Top of Page

Nidal
Starting Member

India
3 Posts

Posted - 03/10/2006 :  11:19:50  Show Profile
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
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000