(This may be a repeat of sorts, but I think it got buried at the end of my previous question.)
Ok, now I'm trying to get one additional piece of data out of my "many" table, but the grouping seems to be throwing things off (note that this has nothing to do with my "Double Select" question from earlier today, which solved a different problem).
Here's the current select (simplified):
I'd like to add in one more piece of data from the MedicareCheckups table, but if I add it in there's a problem (related to the aggregate function, the Max? or the Group?).
Here's what I thought would work:
I kinda get why it's not working (though an explanation would be great if you have the time), but don't understand how to change it.
Ok, now I'm trying to get one additional piece of data out of my "many" table, but the grouping seems to be throwing things off (note that this has nothing to do with my "Double Select" question from earlier today, which solved a different problem).
Here's the current select (simplified):
Code:
SELECT P.ID, P.LastName, D.LastDate
FROM MedicarePatients P
INNER JOIN (
SELECT ID, MAX(Checkup) AS LastDate FROM MedicareCheckups
GROUP BY ID
) D ON P.ID = D.ID
Here's what I thought would work:
Code:
SELECT P.ID, P.LastName, D.LastDate, [COLOR=blue][b]D.Scheduled[/b][/color]
FROM MedicarePatients P
INNER JOIN (
SELECT ID, [COLOR=blue][b]Scheduled,[/b][/color] MAX(Checkup) AS LastDate FROM MedicareCheckups
GROUP BY ID
) D ON P.ID = D.ID