Select a random sample of results from a query result

后端 未结 8 781
-上瘾入骨i
-上瘾入骨i 2020-11-30 20:14

This question asks about getting a random(ish) sample of records on SQL Server and the answer was to use TABLESAMPLE. Is there an equivalent in Oracle 10?

8条回答
  •  星月不相逢
    2020-11-30 20:21

    SELECT * FROM TABLE_NAME SAMPLE(1)
    

    Will give you olny an approximate 1% share rather than exactly 1/100 of the number of observations. The likely reason is than Oracle generates a random flag for each observation as to whether include in in the sample that it generates. The argument 1 (1%) in such a generation process takes the role of probability of each observation's being selected into the sample.

    If this is true, the actual distribution of sample sizes will be binomial.

提交回复
热议问题