If there are arbitrary sorting requirements then create a column to sort on:
select a, (left(a, position('-' in a)), arbitrary_order)
from (
select 'Cardiac - ACS' as a, 9 as arbitrary_order
union
select 'Cardiac - All', 0
) s
order by 2, 1
;
a | row
---------------+-----------------
Cardiac - All | ("Cardiac -",0)
Cardiac - ACS | ("Cardiac -",9)
The default for the arbitrary_order column will be something like 9 or 999 and the arbitrary cases will have lower values.
Or test for the existence of the '- All' string
select a, (
left(a, position('-' in a)),
substring(a from position('-' in a)) != '- All'
)
from (
select 'Cardiac - ACS' as a
union
select 'Cardiac - All'
) s
order by 2, 1
;
a | row
---------------+-----------------
Cardiac - All | ("Cardiac -",f)
Cardiac - ACS | ("Cardiac -",t)
ORDER BYright.SHOW lc_collateto find out).select 'Cardiac __ ACS' as a union select 'Cardiac _ All' as a order by a??