我有一张满是杂志的桌子,需要提取每本杂志的最新一期。
我试过了
SELECT DISTINCT
magazine
FROM
product p
INNER JOIN
(SELECT
title, MAX(onSale) AS Latest
FROM
product
GROUP BY magazine) groupedp
它返回不同的杂志,但不返回我需要的其余数据。
更新:
图式
-id----onsale----magazine
1 1/12/12 Fishing Mag
2 1/11/12 Fishing Mag
3 12/03/11 Pencil Sharpening Monthly
4 1/02/10 Pencil Sharpening Monthly
5 16/04/09 Homes in the Sky
所以我想要返回的结果是:
-id----onsale----magazine
1 1/12/12 Fishing Mag
3 12/03/11 Pencil Sharpening Monthly
5 16/04/09 Homes in the Sky