mardi 26 juillet 2016

Get random data from sql but no repeated values

I need to get 10 random rows from table at each time, but rows never repeat when repeat the query

But if i get all rows it will repeat again from one, like table have 20 rows, at first time i get 10 random rows and 2nd time i will need to get remaining 10 rows at my 3rd query i need to get 10 rows randomly.

Currently my query for getting 10 rows randomly

select top 10 * FROM tablename
ORDER BY NEWID()   




Aucun commentaire:

Enregistrer un commentaire