Hey all, I have a sql statement that selects TOP 7 records from a table but they are not unique. I do not want to have duplicate people. Let me post the sql and then explain.
I have 2 tables, 1 called artists and 1 called images. I'm trying to get the TOP 7 random Artists to show up. Then i joined the IMAGES table to grab one of the artists' images (randomly) and the corresponding ITEMID for that image that was grabbed. With the code provided i get random records but I get duplicate Artists. How can i make it so the TOP 7 artists are unique and randomly chosen with each artists random piece of art and the art's corresponding ITEMID? thanks all!
SELECT TOP 7 artists.artistID, artist, imageID, itemID
INNER JOIN Images
GROUP BY artists.artistID, artist, imageID, itemID
ORDER BY NEWID()