dbTalk Databases Forums  

Help With SQL Statement

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Help With SQL Statement in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andy
 
Posts: n/a

Default Help With SQL Statement - 02-23-2009 , 09:31 AM






Hi Gang

I have a table that has the following.

Part Revision
AA1234 1
AA1234 2
AA1234 3
BB8877 1
BB8877 2
CC3211 1
CC3211 2
CC3211 3
CC3211 4

I want to create a query that will only pull out latest or (max)
revisions. So I want a query that would only return.

AA1234 3
BB8877 2
CC3211 4

Does anyone know how to do this?

Thanks
Andy

Reply With Quote
  #2  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: Help With SQL Statement - 02-23-2009 , 10:23 AM






Andy escribió:
Quote:
Part Revision
AA1234 1
AA1234 2
AA1234 3
BB8877 1
BB8877 2
CC3211 1
CC3211 2
CC3211 3
CC3211 4

I want to create a query that will only pull out latest or (max)
revisions. So I want a query that would only return.

AA1234 3
BB8877 2
CC3211 4

Does anyone know how to do this?
SELECT Part, MAX(Revision) AS MaxRevision
FROM Whatever
GROUP BY Part



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--


Reply With Quote
  #3  
Old   
Michael Austin
 
Posts: n/a

Default Re: Help With SQL Statement - 02-25-2009 , 01:05 PM



Andy wrote:
Quote:
Hi Gang

I have a table that has the following.

Part Revision
AA1234 1
AA1234 2
AA1234 3
BB8877 1
BB8877 2
CC3211 1
CC3211 2
CC3211 3
CC3211 4

I want to create a query that will only pull out latest or (max)
revisions. So I want a query that would only return.

AA1234 3
BB8877 2
CC3211 4

Does anyone know how to do this?

Thanks
Andy
yes we know how to do this... the only hint I would give since you
haven't even shown us what you tried is one of the key words in your
request... search for MAX and you will find it. If you ask someone else
to do your homework for you, how will you ever learn?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.