One way to pick 5 distinct photographers is to use the row_number function as follows:SELECT * FROM(SELECT DISTINCT TOP 15 G.Lastname as Lastname, G.SubDirectory as SubDirectory, G.Firstname as Firstname, G.Gallery as Gallery, G.Custnumber as Custnumber, I.ImageNumber as Imagenumber, I.ImagePosition as ImagePosition, I.RecordNo, I.ImageSizeList, I.GeneralRandomNo as GeneralRandomNo, p.ImgQty as ImageQTy, P.Subdirectory as Portfolio, P.DateTime as DateTime, p.ExhibitionOpened, P.RandomNo, P.AutoID as AutoID, I.PortfolioName, newid() as RandID,ROW_NUMBER() OVER (PARTITION BY G.Lastname, G.FirstName ORDER BY NEWID()) AS RNFROM ArtistSetup G INNER JOINArtistPortfolios P ON G.Custnumber = P.Custnumber INNER JOINArtistIndividualWorks I ON P.SubDirectory = I.PortfolioName AND I.Custnumber = G.CustnumberWHERE P.ImgQty>0 AND G.Gallery='PhotoBistro' and I.ImagePosition=1 and P.ShowcaseOK=1) Rwhere RN = 1Order by ExhibitionOpened desc
You have to be on SQL 2005 or higher to do it this way.