|Re: [firebird-support] How to return the value of a sub-query as a field in the resulting table
> Just a question: Why must "every filed that is not an aggregate must beThe quick answer is that the SQL standard requires that non-aggregated
> in the group list"?
fields in the select list of a grouping query be in the grouping list. A larger
answer is that unless a field is functionally dependent on a grouping field,
the value returned would be some one of the values in the group, but not
necessarily any predictable value.
For example, if you have a table of teams and players with several players
with the same team, you can group by teams and get the number of players
on a team, their average height, their total weight, but if you ask for a player
name ... well you could get any name. Assuming that each team has only
one home field, then home field would be retrieved reliably, because home
field is functionally dependent on team.