[Wranglers] Stratified sampling using SQL given an absolute sample size

Ali, Saqib docbook.xml at gmail.com
Tue Feb 4 14:55:13 UTC 2025


 <https://stackoverflow.com/posts/79410624/timeline>

I have the following population:

a
b
b
c
c
c
c

I am looking for a SQL statement to generate a stratified sample of
arbitrary size. For example, I would like a sample size of 4. I would
expect the output to be:

a
b
c
c

What is the best way to implement this in SQL?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://analyticsengineering.net/pipermail/wranglers/attachments/20250204/3a7e628f/attachment.htm>


More information about the Wranglers mailing list