A real pain, innit?
I have a couple of "disaster queries" with that requirement. I build them up with lots of interpolation so that as conditions change, I am sure that they change the same way in the WHERE, a CASE statement in the SELECT, and the corresponding CASE statement in the GROUP BY. :-(
Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]