[thelist] SQL: summing and counting the same field, based on value
Canfield, Joel
JCanfield at PacAdvantage.org
Tue Jun 13 16:21:54 CDT 2006
> select sum(end - start), count(case type when 9 then 1 else 0 end)
> from ...
> group by type
you and Tab both had a good idea; problem is, it still returns four
values, it's just that three of them are now zero instead of the real
count. I need this to return only one value: that for type = 9.
I'm sorting out a workaround in the script, but I'm still interested in
how one could do this with SQL
joel
More information about the thelist
mailing list