In SQL Server, the following query would give you what you need (if I understand your question):
Code:
SELECT *
FROM table a
INNER JOIN (SELECT date = MAX(date),
symbol,
group
FROM table
GROUP BY symbol, group
) b ON (a.date = b.date AND
a.symbol = b.symbol AND
a.group = b.group
)
In MySQL, I *think* the query can be rewritten like this:
Code:
SELECT *
FROM table a
INNER JOIN (SELECT date = MAX(date),
symbol,
group
FROM table
GROUP BY symbol, group
) as b ON (a.date = b.date AND
a.symbol = b.symbol AND
a.group = b.group
)
The only thing that's different in the second version is the "as b" part when aliasing the derived table.
Bookmarks