Suppose we have a set of data with 5000 records and we need to write a query that helps us every time we are required to fetch 50 Random rows from that table?
How will you do that?
Answer: SQL Server and Oracle Random functions.
Sql Server:
Code
SELECT *Code
FROM ID_CityMstCode
ORDER BY RAND()Code
LIMIT 5Oracle :
SELECT *
FROM
(
SELECT *
FROM id_citymst
ORDER BY
dbms_random.value
)
WHERE rownum <= 6

Join the conversation! Your thoughts help the community grow.