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:
SELECT * FROM ID_CityMst ORDER BY RAND() LIMIT 5 Oracle :
SELECT *
FROM
(
SELECT *
FROM id_citymst
ORDER BY
dbms_random.value
)
WHERE rownum <= 6

Comments
Join the conversation! Your thoughts help the community grow.