* Jose Miguel Pérez
> Let me explain this, as I don't write english very well and I can get
> misunderstood.
>
> Given the following data:
>
> age | name
> -----------
> 30 | John
> 30 | Peter
>
> And the following SELECT:
>
> SELECT age, name FROM <data> GROUP BY age
>
> What would you get?
>
> Answer A)
>
> age | name
> ------------
> 30 | John
>
> Answer B)
>
> age | name
> ------------
> 30 | Peter
>
> Please check only one. :-D
Actually, I got (A) by testing. ;-) However, should you? The result
looks like it is arbitrary, and another day, you get (B).
Anyway, my question (frustration) does not seem to be interesting in
mysql as you can get such answers. In Oracle, you select statement is
not possible at all:
select age,name from foo group by age
*
ERROR at line 1:
ORA-00979: not a GROUP BY expression
Oracle only accepts expressions that are possible to do something
grouping of, like functions of count, max, average and so on. In this
case, given a SELECT expression like the one I started with:
SELECT a,b,c,f(d),g(e) FROM foo GROUP BY a,b,c;
Only a,b,c are possible at the GROUP BY. But when I see that mysql
accepts more, I still cannot see what for.
--
Jon Haugsand, Jon-H.Haugsand@stripped
http://www.norges-bank.no