Subject | Re: Possible bug with GROUP BY and UNION |
---|---|
Author | Salim Naufal |
Post date | 2004-07-12T13:46:34Z |
Wow, I was not aware of the UNION ALL clause.
Thanks Arno
Salim
--- In firebird-support@yahoogroups.com, "Arno Brinkman"
<firebird@a...> wrote:
Thanks Arno
Salim
--- In firebird-support@yahoogroups.com, "Arno Brinkman"
<firebird@a...> wrote:
> Hi,automaticly a
>
> > Then execute the following query:
> >
> > SELECT SUM(AMOUNT)
> > FROM TBL
> > WHERE TYPE_OF_ROW = 0
> > GROUP BY TYPE_OF_ROW
> > UNION
> > SELECT AMOUNT
> > FROM TBL
> > WHERE TYPE_OF_ROW <> 0
> >
> > The expected result is:
> >
> > 11.00
> > 11.00
> > 12.00
> >
> > Instead, the result is
> >
> > 11.00
> > 12.00
>
> That's the different between UNION and UNION ALL. Without ALL
> DISTINCT is performed on the resultset.
>
> Use this query:
>
> SELECT
> SUM(AMOUNT)
> FROM
> TBL
> WHERE
> TYPE_OF_ROW = 0
> GROUP BY
> TYPE_OF_ROW
> UNION ALL
> SELECT
> AMOUNT
> FROM
> TBL
> WHERE
> TYPE_OF_ROW <> 0
>
> Regards,
> Arno Brinkman
> ABVisie