Home
Forum: "Bases";
Current archive: 2002.01.08;

Down

#### Column Sum Pro Find similar branches

SklifF   (2001-12-03 19:08) [0]

There are 3 columns 1: hours, 2: minutes, 3 seconds
What is the best way to make a request so that it performs a summation of all three columns line by line, but taking into account that in minutes 60 seconds, etc.

Dick Gonsales   (2001-12-04 04:25) [1]

SELECT
(SUM (CONVERT (NUMERIC (2,0), (f_hour))) * 3600 +
SUM (CONVERT (NUMERIC (2,0), (f_min))) * 60 +
SUM (CONVERT (NUMERIC (2,0), (f_sec)))
) as sec_time
FROM tmp_time

so you get the total number of seconds
using a party procedure through the remainder
integer division, Sybase supports these functions

unfam   (2001-12-04 04:27) [2]

You mean like this:
select sum (1) * 3600, sum (2) * 60, sum (3) from ... or not?

Dick Gonsales   (2001-12-04 04:51) [3]

Re unfam
Not really, but the meaning is true
You get
total hours in seconds, total minutes in seconds, total seconds in seconds
it will then have to be summarized anyway for human translation
in kind
"Total time spent -"
1 year 2 months 20 days 23 hours 10 minutes 34 seconds
And I suggest immediately getting the total number of seconds for the server
it doesn’t strain, and then it’s more convenient to process it.

In general, you can pervert and count it all in and in SELECT,
but the bells and whistles are crazy and will work many times longer.
It's easier to write such a SELECT and a procedure that
turns the number of seconds into yy-mm-dd hh: mm: ss

unfam   (2001-12-04 09:21) [4]

MVova   (2001-12-04 10:32) [5]

And the question then sounds "line by line"

MVova   (2001-12-04 10:34) [6]

Much more suitable
select 4 = (sum (1) * 3600 + sum (2) * 60 + sum (3)) from ...

SklifF   (2001-12-04 10:54) [7]

Thank you very much for the tips.

Pages: 1 whole branch

Forum: "Bases";
Current archive: 2002.01.08;