Re: select MAX and get the recode??
Posted in 1996
> How can I select the max value and get the whole record?
>
> item_num order_num price customer Date
> -------------------------------------------------------------------
> 1 100 $198 David 1996/1/1
> 1 101 $187 Scott 1996/2/1
> 1 103 $887 Lana 1996/3/1
> 2 101 $776 Lee 1996/6/2
>
> Select max(order_num) from items where item_num = 1;
>
> can get order_num=103, BUT, how can I also get the ("$887", "Lana", "1996/3/1")
> ???
Well, it's not elegant, but how about:
SELECT *
FROM items
WHERE item_num = 1
AND order_num IN (SELECT max(order_num) FROM items WHERE item_num = 1)
?
HTH.
--
Ciao,
Billy
+------------------------------------------------------------------------------+
| I used to be indecisive, but now I'm not so sure... |
+------------------------------------------------------------------------------+