Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL wählt DISTINCT nach dem höchsten Wert aus

SELECT 
    p.*
FROM
        product p
    INNER JOIN
        ( SELECT 
              magazine, MAX(onSale) AS latest
          FROM
              product
          GROUP BY 
              magazine
        ) AS groupedp
      ON  groupedp.magazine = p.magazine
      AND groupedp.latest = p.onSale ;