IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

select max version from table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Mar 06, 2008 4:11 am
Reply with quote

hi

i have a table with cols ref_id and version. now the data is

Code:
ref_id    ver
__________

A           1
A           2
A           3
A           4
B           1
B           2

now i need a query to get the max version of a ref_id.

ie i need my output rows to be A 4 and B 2

Kindly help.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Mar 06, 2008 4:47 am
Reply with quote

OK, have you looked at a SELECT statement and the WHERE clause with a MAX parameter?
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Thu Mar 06, 2008 3:12 pm
Reply with quote

Hi ashimer,

SELECT REF_ID, MAX(VER) FROM <TABLE-NAME>
GROUP BY REF_ID.

will give you the maximum VERSION for ever REF_ID
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top