I'm trying to return just 1 row for every size, brand and kind but sometimes there are multiple rows with the exact same values except enddate
.
I want to return the row with the highest enddate
(Order by enddate
desc) doesn't work.
SELECT
promotion.id,
promotion.uid,
promotion.promotion_id,
promotion.url,
promotion.shop_id,
promotion.brand_kind_id,
promotion.before_price,
promotion.after_price,
promotion.brand_id,
promotion.brand_package_id,
promotion.brand_size,
promotion.amount,
promotion.begindate,
promotion.enddate
FROM
`promotion`
WHERE
AND (promotion.url is not null AND promotion.url != '')
GROUP BY
promotion.brand_id,
promotion.brand_kind_id,
promotion.brand_size
ORDER BY
promotion.enddate DESC