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

Wählen Sie die neuesten MySQL-Daten, aber ein einzigartiges Resort

Angenommen, die ID-Spalte ist eindeutig:

SELECT T3.*
FROM yourtable AS T3
JOIN
(
    SELECT T2.resort, T2.date_added, MAX(T2.id) AS id
    FROM yourtable AS T2
    JOIN
    (
        SELECT resort, MAX(date_added) AS date_added
        FROM yourtable
        GROUP BY resort
    ) AS T1
    ON T1.resort = T2.resort AND T1.date_added = T2.date_added
    GROUP BY T2.resort, T2.date_added
) AS T4
ON T4.id = T3.id