db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bogdan Vatkov" <bvat...@globaltech-bg.com>
Subject Re: Correlated sub query in torque
Date Fri, 21 May 2004 13:46:04 GMT
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: <noel_fuentes@freddiemac.com>
To: "Apache Torque Users List" <torque-user@db.apache.org>
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: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message