On Fri, 2002-07-26 at 15:46, Aman Raheja wrote:
> I have the following situation
> 
> ID    GRP     PRC     CHECK
> 1     3       10.0    Y
> 2     2       12.0    Y
> 3     3       32.0    N
> 4     1       5.0     N
> 5     1       7.0     Y
> 6     2       9.0     N
> 7     3       17.0    N
> 8     1       11.0    N
> 
> Problem is that the sql version I am running does not support sub-queries. 
> Is there another way of getting around the following situation to wirte a 
> query so that
> 
> select * from tab_name where
> one item from each GRP 1, 2, and 3  - whichever is highest priced (PRC) and 
> has CHECK set to N.

Hi, 

Try this: 

SELECT ID,GRP,max(PRC) FROM tab_name 
WHERE GRP IN (1,2,3) and CHECK='N' GROUP BY GRP;

Hope this helps,

-- 
Diana Soares


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to