MySQL select DISTINCT by highest value

后端 未结 5 566
刺人心
刺人心 2021-01-05 06:52

I have a table full of magazines, and need to extract the latest unique issue of each magazine.

Ive tried

    SELECT DISTINCT
    magazine
        F         


        
5条回答
  •  悲哀的现实
    2021-01-05 07:19

    You need to put the 'rest of data' in the first select:

    SELECT DISTINCT magazine, "rest of data"
    FROM product p 
    INNER JOIN 
    ( SELECT title, MAX(onSale) AS Latest 
    FROM product 
    GROUP BY magazine ) groupedp
    

提交回复
热议问题