I think this is what you want: The last 4 albums, plus the last song on each. Since you don't mention a date field in the album table, I am using ID:
SELECT TOP 4 *
FROM albums_table a
INNER JOIN madia_table m ON m.ID=(
SELECT TOP 1 m2.ID
FROM madia_table m2
WHERE m2.albumID=a.ID
ORDER BY createDate DESC
)
ORDER BY a.ID DESC
-Tab Alleman
Marked as answer by Chen Yu - MSFT on May 14, 2012 11:23 AM
TabAlleman
All-Star
15711 Points
2718 Posts
Re: select distinct from multipale tables
May 01, 2012 01:24 PM|LINK
I think this is what you want: The last 4 albums, plus the last song on each. Since you don't mention a date field in the album table, I am using ID: