Subject RE: [firebird-support] Selection/group order causes an error
Author Alan McDonald
> I have an odd scenario with an SQL statement. I've been able
> to narrow down the issue to a basic SQL statement that you
> can duplicate on any FB database. Run the following statements:
>
> select cast(rdb$security_class as varchar(80)), 1
> from rdb$database
> group by 1, 2
>
> select cast(rdb$security_class as varchar(80)), 1
> from rdb$database
> group by 2, 1
>
> The first one passes, and the second one fails. I'm using FB
> 1.5.4 and I know I can't use a function (like cast) in the
> group by clause so I'm referencing these by ordinal value.
> Why would one work and not the other?
>
> Thanks in advance,
> Paul

I suspect because the aggregating requirement is met by the integer 1 in the
first statement but not the cast field in the second.
In fact both statements are nonsense
select cast(rdb$security_class as varchar(80)), 1
from rdb$database
group by 1
Is more legal of the 2
i.e. the non aggregating field only should be specificed in the group by
clause.
But since no aggregating function at all is being called in either of your
statements, they don't make sense.
What do you THINK you are aggregating by use of the "group by"?
Alan