-1

I have the following data

    Shift_Working_Hours
    --------------------
    03:45
    09:00
    08:45
    07:50

I want to add up all the values in the Shift_Working_Hours column and I want the result as 28:40. Please guide me how can i do it using SQL. I am using TOAD.

user3152738
  • 9
  • 1
  • 1
  • 1

1 Answers1

0
-- If it String Column



  Select convert(varchar,sum(convert(int,parsename(replace(WH,':',''),2)
    +(sum(convert(int,parsename(replace(WH,':',''),1)/60))+':'
    +convert(varchar,(sum(convert(int,parsename(replace(WH,':',''),2)%60))
    from table


    -- If it is a datecolumn
Select convert(varchar,SUM(DATEPART(hh,Wh))+
SUM(DATEPART(mm,WH))/60)+':'+
convert(varchar,SUM(DATEPART(mm,WH))%60)
Azar
  • 1,852
  • 15
  • 17