Sampling data via SQL

Did you ever want to sample some records from your file? Check out this tip to learn how.

Did you ever want to sample some records from your file? For instance, you want to just see or work with every 10th record. Using SQL and some of its functions, you can do just that. Using the Mod and RRN functions you can select your sample. Just use the number as the second argument in the Mod function for the nth value. Mod returns the remainder so if the remainder is 0, you have the desired record.

SELECT PART#, DESC, PRICE FROM ITEMS WHERE MOD(RRN(ITEMS),10)=0

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.


This was first published in October 2001

Dig deeper on iSeries CL programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close