This will do the trick. You will need to replace testtable with the name of your table.
SELECT t.priority FROM dbo.testtable t ORDER BY (CASE WHEN t.priority = 0 THEN 2147483647 ELSE t.priority END)
If this is not clear, I chose 2147483647, because this is the maximum value of the priority column, so it will be the last.
Itβs better to mark the answer, and defo to go.
source share