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
 General SQL Server Forums
 New to SQL Server Programming
 Sum of 2 columns

Author  Topic 

nikoo56
Starting Member

26 Posts

Posted - 2012-02-22 : 13:02:18
I have a report that shows the query below as 2 column, columns are time formatted, means for example it shows as 2:30 and 4:20, I like to have a third column that shows the sum of this 2 columns how I can make it?

(select top 1 convert(varchar,datediff(hour, p.dt_created, time_stamp))
+':'+convert(varchar,datediff(Minute, p.dt_created, time_stamp)%60)from tblAdmRepChangeLog th (nolock) where th.stu_rec_num = p.stu_rec_num order by cl_id asc)[xfer_1_elapsed],

AND
(select top 1 ltrim(minutes/60) +':' + LTRIM(minutes%60) as Elapsed

from (select top 2 datediff(minute, p.dt_created, time_stamp) as minutes,

cl_id from tblAdmRepChangeLog th (nolock) where th.stu_rec_num = p.stu_rec_num order by cl_id asc) q1 order by cl_id desc) [xfer_2_elapsed],

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-22 : 13:20:39
What do you mean by SUM of 2 times attributes?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

nikoo56
Starting Member

26 Posts

Posted - 2012-02-22 : 16:12:04
with Sum I mean, for example 1 column return 2:30 and 1 column return 3:30, shows 5:50 as Sum.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-22 : 18:47:34
don't you mean 6:00

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

nikoo56
Starting Member

26 Posts

Posted - 2012-02-23 : 17:50:52
OK 4:20 + 2:30 = 6:50
So I want to have a new column that shows 6:50. Or Any other sum of 2 column.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-23 : 18:03:52
quote:
Originally posted by nikoo56

OK 4:20 + 2:30 = 6:50
So I want to have a new column that shows 6:50. Or Any other sum of 2 column.


what if its

4:40 + 2:40?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-23 : 19:42:40
Whatever...can you tell us what sense this makes?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -