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

Maximum and Minimum Value fetch


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

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Tue Aug 25, 2009 11:51 am
Reply with quote

Hi,

The requirement is like this:

We have certain Organization and Institutions,and each Organization can have more than one Institutions.

Ex:

Org Id Institution Id
1 100
1 101
1 102
1 199
2 200
2 500
2 501
2 510
2 511
2 512

The expected results should be as below:

Organization Institution Groups
1 100-102,199
2 200,500-501,510-512

Is there a way we can do this through DB2 query? icon_rolleyes.gif
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Tue Aug 25, 2009 12:17 pm
Reply with quote

Please you could explain how exactly you want is the requirement, I am not getting in what format you the exact output.
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Tue Aug 25, 2009 12:23 pm
Reply with quote

Hi Ketan,

The expected result is 2 coulmns from the query-Org Id and Institution Id groupings, where Org Id will contain the Organization id's and the second column will contain the Institution groups given above.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Aug 25, 2009 1:18 pm
Reply with quote

Quote:

100-102,199


MAx and Min value fetch - what applies here ?
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Tue Aug 25, 2009 1:51 pm
Reply with quote

ashimer,

I guess we need to use both.With the below data

Org Id Institution Id
1 100
1 101
1 102
1 199
2 200
2 500
2 501
2 510
2 511
2 512

We need to fetch the maximum and minimum in a particular range.I am not sure whether this is doable using a single query.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 25, 2009 7:33 pm
Reply with quote

Hello,

Quote:
2 200,500-501,510-512
Why are there 2 "ranges" in the 500 series? I believe i understand, but this has not been explained.
Quote:
I am not sure whether this is doable using a single query.
Probably not. . .
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 Fetch data from programs execute (dat... DB2 3
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts SORT ERROR PARAMETER VALUE EXCEEDS M... DFSORT/ICETOOL 12
No new posts fetch the record number from FMNMAIN ... CLIST & REXX 10
Search our Forums:

Back to Top