Ranking when multiple options are available


When trying to fill gaps in a table, i can use a lookup in another table B to find the missing data. But this gap filter table B could have more than one option of data that are ranked

create table table_gappy(
  transport_used varchar(50),
  t_out varchar(10)

insert into table_gappy
select null, 'vader'

create table table_lookup(
transport_used varchar(50),
  t_in varchar(10),
rank int

insert into table_lookup
select 'the dark force', 'vader', 1 union
select 'anger', 'vader',2  union
select 'sith-ing', 'vader',3

so in this case use the dark force but there could be situations where that might not exist so I need to account for that and select anger but maybe that does not matter as it would be the top most whatever it is.

As I type it is becoming clearer what I might need to do :rofl: wow this is therapeutic :rofl:

:footprints: baby steps. What about Bob