![using sql rand to a number of records from a file at random](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisuIXN-tSxhiA8PDIbVd9Uz4H-CLs4rePo-U-McWOcMMD-mAdXHYzhk4EKZl8OR0ByCY_2TCTXiUuCJrg9bZcYgf7pksXa3l0HpoUIFioUmwvmG2jnd_HmEvxnZ7Kf2m74QbI7lRFkGhlh/s200/sql.png)
I have written about using SQL's RAND() to generate random numbers to be included in the returned results, but not to return a fixed number of randomly selected results. In other words I just want five randomly selected rows returned in the results.
In this example I have a file, and yes it is a DDS file, that contains just two fields:
- COMPANY: company number
- VALUE: a three long numeric field
For company number 1 there are twenty records with the sequential values 1 – 20.
The request is for, let's say, five randomly selected records for company number 1 only.