soozh
asked on
Select statement Pervaise.SQL
Hello,
I have database table with rows that contain a patient id, sequence no and a value. I want to return ONE row for each patient where the sequence no is highest. The sequence no represents the visits and i want return data from the last visit.
See that data below and the returned dataset.
I have database table with rows that contain a patient id, sequence no and a value. I want to return ONE row for each patient where the sequence no is highest. The sequence no represents the visits and i want return data from the last visit.
See that data below and the returned dataset.
Pat id seq Value
A 1 23
A 2 17
A 3 25
B 1 17
C 1 24
C 2 16
Returns
A 3 25
B 1 17
C 2 16
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select patid,max(seq),value from patient group by patid