Click here to Skip to main content
14,270,872 members
Rate this:
Please Sign up or sign in to vote.
Hi Friends,

I want sql query for the below

Hrs1             Hrs2  
10                12
8                 10
15                7



I want to take sum(sum(Hrs1),sum(Hrs2)) as Total

I tried the above query but it will shows an error. Please anyone help me.

Thanks,
Nandha
Posted
Updated 6-Aug-13 23:03pm
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try sum(Hrs1)+sum(Hrs2) as Total
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

select hrs1 + hrs2 as totalhrs from tableName

OR
--for summary, this will give single row as answer.
select sum(hrs1 + hrs2) as totalhrs from tableName

Happy Coding!
:)
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

SELECT (SUM(hrs1 )+SUM(hrs2)) as 'totalhrs' from tableName.this can get
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

try this...:)


SELECT Tot = ISNULL(Value1, 0) + ISNULL(Value2, 0)
FROM Table
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100