[thelist] SQL: summing and counting the same field, based on value

Canfield, Joel JCanfield at PacAdvantage.org
Tue Jun 13 16:42:42 CDT 2006


> ?    You mean that on every row you want it to return the 
> Count of type=9?

no, the count of type=9 *where all the rest of the 'where' criteria are
met as well*

for instance, I'm looping through multiple call center reps, multiple
dates, gathering info for all four types. for all four, I want the sum
of time spent in each state/type. that's done.

the other bit is, for each agent, for each date, I want to know the
count of type = 9.

so is the solution really to create a subquery where I repeat all the
'where' criteria? if this really isn't doable elegantly in SQL, I'll
just do it in the scripting. just hoping there was a simple elegant SQL
method.

thanks



More information about the thelist mailing list