[thelist] MySQL: counting ranges of values

Canfield, Joel JCanfield at PacAdvantage.org
Thu May 11 18:04:11 CDT 2006


I have a query which returns the duration of calls from a calculation. I
need to get counts, grouped by <= XX, XX < duration <= YY, YY <
duration.

and for the life of me I can't work up how to write the query.

The select portion is

   Select count(If (c.SameGroup = 1, c.UnixWaitTimeEnd -   
     UnixWaitTimeStart4SameGroup,
          If (c.susrCreationUnixTimestamp < 100000,0,c.UnixWaitTimeEnd -

              c.susrCreationUnixTimestamp))) As WaitTime

but it won't let me use WaitTime as a comparison (where WaitTime <= 20,
for instance.)

Probably childishly simple, but it's not coming to me.

thanks



More information about the thelist mailing list