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

Suggest me a SQL query for the following problem


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

New User


Joined: 17 Oct 2005
Posts: 2

PostPosted: Sun Nov 27, 2005 2:20 pm
Reply with quote

Hi

Input

FIN__NUM MACH_MODEL MACH__NUM
2 6C1 3C24A
1 6C1 3C24A
1 6C1 3C26A
2 6C1 3C27A

oUPUT SHOULD CONTAINS
FIN__NUM MACH_MODEL MACH__NUM
2 6C1 3C24A
2 6C1 3C27A


PLEASE suggest a query for the above . it is not mandatory that fin_num should be always 2 . the query should extract max of fin_num
Back to top
View user's profile Send private message
aklima

New User


Joined: 25 Nov 2005
Posts: 18
Location: uae

PostPosted: Sun Nov 27, 2005 9:20 pm
Reply with quote

well i think u want the whole record with fin_num to be max
then u can give subquery and i think the 3 are columns then this may be the answer

select FIN__NUM,MACH_MODEL ,MACH__NUM from input where fin_num=
(select max(fin_num) from input)
hope this will be the rgt query
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Nov 28, 2005 12:18 pm
Reply with quote

hi frnd,
As per ur req. the solution given by aklima is right. plz add this also to get in sorted order.

Code:
select FIN__NUM,MACH_MODEL ,MACH__NUM from input where fin_num=
(select max(fin_num) from input) order by MACH_NUM;


let me know if any other.
Back to top
View user's profile Send private message
Suryanarayana.tadala

New User


Joined: 03 Nov 2005
Posts: 43
Location: St.Louis

PostPosted: Mon Nov 28, 2005 9:12 pm
Reply with quote

Hey Frnd's i think it that query should work.

select FIN__NUM,MACH_MODEL ,MACH__NUM from input where fin_num=
(select max(fin_num) from input) order by MACH_NUM;
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top