I have this table
rss_user. You see account name, application name and application type.
with
RSS_USER_NAME RSS_NAME RSS_TYPE
example data
tom@gmail.com webapp4 webapps
tom@gmail.com webapp6 webapps
tom@gmail.com mswin3 windows
tom@gmail.com mswin2 windows
sakur@gmail.com mswin2 windows
sakur@gmail.com webapp6 webapps
I wish to get one random account from the combination of rss_name and rss_type. Every combination of rss_name and rss_type should have one random account.
current code. Completly useless 🙁
SELECT *
FROM ( SELECT 'SYNC rss_user WITH rss_user_name = "'
|| RSS_USER_NAME
|| '" , rss_name = "'
|| RSS_NAME
|| '" , rss_type = "'
|| RSS_TYPE
|| '";'
FROM rss_user
ORDER BY DBMS_RANDOM.VALUE)
WHERE ROWNUM = 1
result:
SYNC rss_user WITH rss_user_name = "tom@gmail.com" , rss_name = "webapp4" , rss_type = "webapps";
Here is an approach:
That is, use row_number() and dbms_random.value with each other to select a random row.