Skip to content
Advertisement

Select random rows with no duplicates

I need to select a random amount of rows but also ensure that the rows don’t contain duplicate Image values:

I have done a – select top 25 percent * from Table order by newid(); This works for the random side of things but it brings back duplicate. I have tried a distinct but it doesnt like the order by part. Basically is there a better way to show just show a random 3 Images that are not duplicates.

Advertisement

Answer

looks like you have multiple images with different ImgID

maybe you want something like this to get unique images

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement