Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us