Avatar of tim_Burgess
tim_Burgess
 asked on

MSSQL - Analytic function help

Please see the attached witch shows

fig1. current output from tbl_assessments
fig2. desired output from the same table

I want the output to show an additional column (first_assessment_id). This will get the assessment ID from the assessment with the earliest end_date for the person and repeat it for every subsequent assessment for the person. I tried something like

min(ssca_id) over (partition by ssca_dim_person_id order by ssca_dim_person_id, ssca_end_date asc)

but found this didn’t work as the earliest assessment_id recorded for the person was not always a lower number than subsequent assessments for the person

any help is appreciated.
sample-data-20181025.xlsx
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
awking00

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
lcohan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
tim_Burgess

ASKER
thankyou
SOLUTION
awking00

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
tim_Burgess

ASKER
thankyou awking00, thats a neat solution
awking00

uw :-)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck