NB
Select distinct first_value(ch.channel_id) over (order by case when is_valid=‘TRUE’ THEN 1 ELSE 0 END DESC, priority DESC
rows between unbounded preceding and unbounded following)
From client cl
Join channel ch
On cl.channel_id = cl.channel_id
Size: a a a
NB
S
NB
S
NB
ORDER BY
or use ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
. S
R
DK
AS
N
S
S
AS
ДН
T
T
ДН
T
GP