Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Query HELP!

Query HELP!

From: contrapositive <nosp_at_m.com>
Date: Fri, 25 Jan 2002 19:33:25 -0500
Message-ID: <3c51f92a$1_2@nopics.sjc>


This is an Oracle 8i database. Table A contains data as follows (simplified for the sake of clarity):

ID ITEM_CLASS VERSION

1     ABC           12
2     ABC           61
3     ABC           1885
4     PQR           17
5     PQR           825
6     XYZ           1
7    XYZ           55
8    XYZ           56
9    XYZ           59

You get the idea. If I do:
select ITEM_CLASS, max(VERSION)
from A
group by ITEM_CLASS

I get:
ABC 1885
PQR 825
XYZ 59 Now how can I also grab the corresponding ID? Seems straightforward and I'm trying to do it without subqueries as they slow things down to a grind (these are large tables). If a subquery is the only way, maybe someone can give me some ideas as to how I may optimize it for performance.

By the way, I don't think ITEM_CLASS is indexed in this case. Thanks in advance.

-jk Received on Fri Jan 25 2002 - 18:33:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US