November 13, 2009 at 9:03 am
I'm stuck here.
I've been trying to find a way to select the latest FinancialYear record for each member from this table (i.e. the highlighted records).
Is it even possible to grab the wanted records in a single query?
November 13, 2009 at 9:36 am
If you aren't dealing with a large amount of data something like this should work.
SELECT * FROM tableName a
WHERE financialYear = (SELECT MAX(financialYear) FROM tableName b
WHERE a.memberID = b.memberID)
November 13, 2009 at 9:56 am
Why not this:
select
MemberID,
max(FinancialYear) as FinancialYear
from
dbo.MyTable
group by
MemberID;
November 13, 2009 at 11:06 am
Yeah, I was assuming the whole row was needed. Probably should have asked what the expected outcome was.
November 16, 2009 at 7:18 am
Thanks Matt & Lynn.
Sorry for not being clear enough. I did want the entire row returned, so I ended up using Matt's script.
Thank you both again for your help 🙂
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply