There are a couple of different ways you could do this.
--#1
ORDER BY CASE WHEN col = 'Enabled' THEN 1
WHEN col = 'Paused' THEN 2
WHEN col = 'Disabled' THEN 3
END ;
The idea here is to create a integer column that maps to the desired
ordering value and sort by it.
-- #2
ORDER BY CHARINDEX( LEFT( col, 1 ), 'EPB' ) ;
The idea here is to find the position of the first character of the column
value in the string 'EPB' and sort by it.
--
Anith
-----------------------------------------------Reply-----------------------------------------------
Thanks! I learned something new!
"Anith Sen" <a
@bizdatasolutions.com> wrote in message
news:OijeMiIqHHA.4496@TK2MSFTNGP06.phx.gbl...
> There are a couple of different ways you could do this.
> --#1
> ORDER BY CASE WHEN col = 'Enabled' THEN 1
> WHEN col = 'Paused' THEN 2
> WHEN col = 'Disabled' THEN 3
> END ;
> The idea here is to create a integer column that maps to the desired
> ordering value and sort by it.
> -- #2
> ORDER BY CHARINDEX( LEFT( col, 1 ), 'EPB' ) ;
> The idea here is to find the position of the first character of the column
> value in the string 'EPB' and sort by it.
> --
> Anith