Subject | Re: [firebird-support] How to return the value of a sub-query as a field in the resulting table |
---|---|
Author | Paul Vinkenoog |
Post date | 2011-04-07T21:31:52Z |
Cornie wrote:
T
Name Age Sex Salary
-------------------------
John 23 M 1000
Jack 24 M 1250
Jill 23 F 1100
And this query:
select age, sex, max(salary) from t
group by age
What value would column Sex have for the row with Age = 23?
Paul Vinkenoog
> Just a question: Why must "every filed that is not an aggregate must be in the group list"?Because otherwise you may get different values in the same column within a single group. Imagine this table:
T
Name Age Sex Salary
-------------------------
John 23 M 1000
Jack 24 M 1250
Jill 23 F 1100
And this query:
select age, sex, max(salary) from t
group by age
What value would column Sex have for the row with Age = 23?
Paul Vinkenoog