Wednesday, 21 August 2013

SQL Server Max Function

SQL Server Max Function

I have the following query:
SELECT
a.name, a.address, n.date, n.note
FROM a
LEFT JOIN n ON a.id = n.id
The a.id has a one to many relationship with n.id, so that many notes can
be assocaited with one a.name.
How do I return just the latest note for each a.name instead of all the
notes?
I'm using SQL Server 2008.
Thanks.

No comments:

Post a Comment