Hello,
I just want to get the value of one column in the row where max of
another col of this table is.
With the possibility of sub queries I would write:
select col1
from table t1
where col2 = (select max(col2)
from tab1e t2);
But how to do it without a sub query?
Just with 1
I could be missing something, but what about:
select col1 from t1 where col2 = max(col2);
On Sun, 12 May 2002 23:04:14 +0200
Sabine Richter [EMAIL PROTECTED] wrote:
Hello,
I just want to get the value of one column in the row where max of
another col of this table is.
With the
Hello Philip,
that was my first choice, too.
But no, error : Invalid use of group function
and select col1, max(col2) from table;
is error 1140: mixing of group cols with non groupĆ¼ cols is illegal
(That would other sql backends say too)
and other variants of the above like select col1
Oh, someone should fix that... I guess it won't let you put a group statement in the
where clause.
Here is another way. On the down side, its a bit more roundabout. On the up side,
however, I actually tried it and it worked.
select col1 from t1 order by col2 desc limit 1;
-Philip
On Sun,
At 23:41 +0200 5/12/02, Sabine Richter wrote:
Hello Philip,
that was my first choice, too.
But no, error : Invalid use of group function
and select col1, max(col2) from table;
is error 1140: mixing of group cols with non groupĆ¼ cols is illegal
(That would other sql backends say too)
And