• sratemo (7/2/2015)


    Hi Jason,

    Your solution looks solid but the query wouldn't execute past:

    "MAX(adg.AdminDateGroup) OVER (PARTITION BY adg.PatientID ORDER BY adg.AdmissionDate) AS AdminDateGroup".

    error - Incorrect syntax near 'order'.

    Tried going around this but then got discrepancies in the results.

    Yea... That's my bad. I knew that 2008 supported windowed aggregates but it looks like it only supports partitioning, not ordering... So completely my fault on that...

    Luckily Dwain was able to step up to the plate and come up with a good working solution. I haven't had a chance to dig into his code but I definitely will. He's always good at supplying fantastic new tools for the toolbox. 🙂