MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Select 5 Rows meeting each condition

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Wed Apr 30, 2008 5:16 pm    Post subject: Select 5 Rows meeting each condition Reply with quote

I had a similar question recently regarding sampling 5 records from a flat sequential file, but now I need to do it with a DB2 query :

Code:
Select name,
     address,
     zip_code
     from mydatabase_mytable
     where zip_code in ('11111','22222','33333')


but I only want 5 of each zip code specified...

Thanks for any help....
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 30, 2008 6:46 pm    Post subject: Reply with quote

tcurrier,

If you are running DB2 Version 9 then you can use RANK OLAP function. Check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=8424&highlight=rank

Hope this helps...

Cheers
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group