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 LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am

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