jeudi 19 mars 2020

Is there a simple way to pick random records (about 20) from a data table with specific condition

Here is the code I used

SELECT * FROM   
(SELECT * FROM [table name] 
ORDER BY dbms_random.value)
WHERE rownum < 10

I would like to select random rows only from records with column A = XYZ. I tried to add a WHERE clause in the code:

SELECT * FROM   
(SELECT * FROM [table name] 
WHERE [column A] = 'XYZ'
ORDER BY dbms_random.value)
WHERE rownum < 10

but got an error. Any feedback would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire