I am trying for the past 2/3 hours to sort a varchar the way I want it, but I could not figure it out. Basically this is the query that comes the closest to what I want:
select Plantmaat
from Plant
Group by Plantmaat
order by (CASE WHEN Plantmaat like '[a-z]%' THEN 0 ELSE 1 END), Plantmaat ASC;
Outputs this:
LEV
PLG
S 10-12
S 12-14
S 14-16
S 16-18
UITS
10
-10
11
12
14
15
-9
But this is what I want to achieve:
LEV
PLG
UITS
S 10-12
S 12-14
S 14-16
S 16-18
-9
-10
10
11
12
14
15
AS you can see the biggest problem here is that it doesn't sort the row that has only letters, and that negative numbers end up at the bottom.