Subject | Re: How many Unions allowed in firebird Select? |
---|---|
Author | Tony Masefield |
Post date | 2005-11-05T20:00:47Z |
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
The problem was with the AVG() - the return data type was not
compatible with the Min and Max -
i.e Select 'Average', Cast(Min(Col_1) as Smallint), Cast(Min(Col_2) as
Smallint) from MyTable etc works OK.
Think I may have misunderstood what you were trying to say and only
cast the first string - i.e Cast('Average' as Varchar(9)) instead of
the whole statement.
Changing the first select to Avg() (from Min()) resulted in the same
error even with one union (it just happened that AVG() was the last of
the two UNIONS).
Casting the AVG() to smallint (as per the column datatype) solved the
problem but I don't understand why when I tried Count() and SUM() also
gave the same error as AVG() - one would have assumed that they would
give the same return type as Min() and Max()?
Thanks for your help and time!
<m.tonies@u...> wrote:
> Ehm, are you doing the CAST with the 3rd union as well?Hi Martijn,
>
> With regards,
>
The problem was with the AVG() - the return data type was not
compatible with the Min and Max -
i.e Select 'Average', Cast(Min(Col_1) as Smallint), Cast(Min(Col_2) as
Smallint) from MyTable etc works OK.
Think I may have misunderstood what you were trying to say and only
cast the first string - i.e Cast('Average' as Varchar(9)) instead of
the whole statement.
Changing the first select to Avg() (from Min()) resulted in the same
error even with one union (it just happened that AVG() was the last of
the two UNIONS).
Casting the AVG() to smallint (as per the column datatype) solved the
problem but I don't understand why when I tried Count() and SUM() also
gave the same error as AVG() - one would have assumed that they would
give the same return type as Min() and Max()?
Thanks for your help and time!