Dear All,
I have a data set that I wish to select unique records from based on the group which they belong to and a priority.
The code below displays three records within a group (indicated by gr_id1). (Note:key1 is unique, ID is not)
I wish to select one record from each group, the one that has the lowest priority.
The code below is not correct but highlights what I wish to do.
Any assistance would be very much appreciated.
Regards,
Geez
I have a data set that I wish to select unique records from based on the group which they belong to and a priority.
The code below displays three records within a group (indicated by gr_id1). (Note:key1 is unique, ID is not)
Code:
select s_id,key1, company, gr_id1, priority
from LDV_selection_pool
where gr_id1=5000034
Code:
ID key1 company gr_id1 priroity
01669417 0759830 First Plc 5000034 1
701947 0372485 First 5000034 3
702148 0372486 First 5000034 3
The code below is not correct but highlights what I wish to do.
Code:
select *
from LDV_selection_pool
where key1 in(
select min(priority), key1
from LDV_selection_pool
group by gr_id1
)
Regards,
Geez