Check out example codes for "stratified sampling sql". It will help you in understanding the concepts better.

Code Example 1

select d.*
from (select d.*,
             row_number() over (order by coursecode, newid) as seqnum,
             count(*) over () as cnt
      from degree d
     ) d
where seqnum % (cnt / 500) = 1;

Learn ReactJs, React Native from akashmittal.com