Xbasic

RANDOM_PERCENT_RECORDS Function

Syntax

Filter_Expression as C = random_percent_records(percent as n[,filter as c])

Arguments

Filter_Expression

An expression that selects records from a table.

percent

An integer number greater than 0 and less than or equal to 100. The count of records to return.

filter

Optional. Default = ".T." (All records). A character filter expression that evaluates to a logical value and selects records from the table.

Description

Return percent of the records, selected at random.

Discussion

Selects a specified Percent of the random records from a table. If the optional filter is supplied, the records are selected only from those that satisfy the filter. Percent is expressed as a whole number, e.g. 50 for 50%. RANDOM_PERCENT_RECORDS() is a special function used only in queries to return a percent of the records,selected at random, in the currently open table. If the optional filter is supplied, the random records are selected from the records selected by the filter.

Example 

See Top, Bottom, Nth Record and Random Record Queries for more information. The following query randomly selects and returns 10% percent of the table's orders placed after May 1, 2000.

dim tbl as P
dim inx as P
tbl = table.current()
query.filter = "random_percent_records(10, \"orderdate > {5/1/2000}\")"
query.order = "order_total"
inx = tbl.query_create()
topparent.resynch()

See Also