오라클
//샘플 sql
//select * from (select * from TEST_TABLE order by dbms_random.value) where rownum <= 5
sSql = " SELECT Q.* FROM \n" +
" (SELECT C.* FROM \n" +
" (SELECT B.* FROM \n" +
" (SELECT ROWNUM NUM , \n" +
" (SELECT COUNT(*) FROM OCCASIONAL_STUDENT WHERE ECLASS_NM = A.ECLASS_NM) CNT2, \n" +
" (SELECT COUNT(*) FROM BOARD_RECORD WHERE SITE_iD=A.ECLASS_NM) CNT,A.* FROM OPEN_LECTURE A \n" +
" WHERE A.LECTURE_GRANT='1' \n" +
" ORDER BY CNT DESC , CNT2 DESC) B \n" +
" WHERE B.NUM<=100) C \n" +
" ORDER BY DBMS_RANDOM.VALUE) Q \n" +
" WHERE ROWNUM <=4";
ms-sql
//샘플 sql
//select top 2 * from (select top 10 * from B_oneword order by idx desc) as x order by newid()
sSql = " SELECT TOP 4 D.* FROM \n" +
" (SELECT TOP 100 A.*, \n" +
" (SELECT COUNT(*) FROM OCCASIONAL_STUDENT WHERE ECLASS_NM = A.ECLASS_NM) CNT2, \n" +
" (SELECT COUNT(*) FROM BOARD_RECORD WHERE SITE_ID=A.ECLASS_NM) CNT \n" +
" FROM OPEN_LECTURE A \n" +
" WHERE A.LECTURE_GRANT='1' \n" +
" ORDER BY CNT DESC , CNT2 DESC) AS D \n" +
" ORDER BY NEWID()";