Query ช่วยสุ่มตรวจสอบตามเกณฑ์ฯ OPD จำนวน 40 ราย (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'A%' ORDER BY RAND() limit 2) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'B%' limit 1) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx between 'D50' and 'D89' ORDER BY RAND() limit 2) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'E%' ORDER BY RAND() limit 2) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'I%' ORDER BY RAND() limit 2) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'J%' ORDER BY RAND() limit 2) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'K%' ORDER BY RAND() limit 2) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'M%' ORDER BY RAND() limit 3) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'O%' ORDER BY RAND() limit 3) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'R%' ORDER BY RAND() limit 3) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'S%' ORDER BY RAND() limit 3) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and pdx like 'Z%' ORDER BY RAND() limit 8) union (select hn,pdx,vstdate from vn_stat where vstdate between 20161001 and 20161231 and( pdx not like 'A%' and pdx not like 'B%' and pdx not between 'D50' and 'D89' and pdx not like 'E%' and pdx not like 'I%' and pdx not like 'J%' and pdx not like 'K%' and pdx not like 'M%' and pdx not like 'U%' and pdx not like 'H%' and pdx not like 'O%' and pdx not like 'R%' and pdx not like 'S%' and pdx not like 'Z%')limit 7) order by pdx