Subject | Re: [firebird-support] Conditional grouping? |
---|---|
Author | Ivan Prenosil |
Post date | 2005-07-28T19:25Z |
> I'm probably being dense, but I can't figure out how to do a conditionalSELECT CASE WHEN UNIT_DOSE IN ('X','U') THEN DOSE_SIZE ELSE NULL END, ...
> grouping.
> I need to sum quantities based on these columns (GPI, TEE, UNIT_DOSE),
> but also on an additional column (DOSE_SIZE) if one of first set
> (UNIT_DOSE) meets certain criteria.
>
> GROUP BY
> GPI, TEE, UNIT_DOSE, (IF UNIT_DOSE IN ('X','U') DOSE_SIZE)
>
> The only thing I could come up with is to do two queries, union them,
> and then sum that.
GROUP BY GPI, TEE, UNIT_DOSE, 1
Ivan