Is this going to do the same:

SELECT

bid.*,

MAX(bid.seq) AS max_seq_4_nbr_group

FROM bid
GROUP BY bid.nbr

If yes, than we could think of a Criteria corresponding code, as the SQL
itself is lighter.

regards,
bogdan
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Apache Torque Users List" <[EMAIL PROTECTED]>
Sent: Friday, May 21, 2004 4:30 PM
Subject: Re: Correlated sub query in torque


>
> key   2ndkey       nbr  seq   amount
> 1     100   100   1     10
> 2     100   100   2     11
> 3     100   100   3     9
> 4     200   101   1     50
> 5     200   102   1     200
> 6     200   102   2     100
> 7     300   103   1     12
>
> select *
> from bid a
> where a.key = (select b.key, max(seq) from bid b where b.nbr = a.nbr and
> b.2ndkey = a.2ndkey group by b.nbr)
> and 2ndkey = 100
>
> thanks,
> nf
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to