Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Suggest me a SQL query for the following problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Suggest me a SQL query for the following problem
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    Post subject:
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: 680
Location: NJ

PostPosted: Mon Nov 28, 2005 12:18 pm    Post subject: DB2 query
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    Post subject: Re: Suggest me a SQL query for the following problem
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts query to fetch record which has only ... maxsubrat DB2 4 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Having a problem FTP'ng to the MF pahiker All Other Mainframe Topics 2 Fri Nov 10, 2017 8:20 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us