Add a new column in the table called "position". Anyway, the name can be any other you want.
For ID 100, save the "position" column as 1, the others leave as 0 or null.
Then at the time of consulting, just sort by the "position" column in the same order with priority over the other sort rules.
select id,nome from CATEGORIA ORDER BY position DESC, nome ASC;
Be aware that it does not mean that it is the best nor the only solution.
I particularly prefer this way compared to other suggestions made because it makes it more flexible. Think about when you need to prioritize a different ID or when you want to reuse the routine for other things. You will have to change the code manually and do various hacks and adaptations.
I found your code much better and more explanatory than the others,.
– Falion
@Falion grateful, the idea was to simplify even. There are other answers that have solved well too, but although we have several answers already, I preferred to show this shorter path.
– Bacco
@Bacco thought mine would be simpler before seeing this, rsrs. + 1 beautiful simplified.
– Marconi
@Marconi ours are very similar, I just gave a "bigger lip on the edges" so to speak. The general line is the same.
– Bacco
@Bacco surely that was a sensational response. :)
– Marconi
Very good, I didn’t know I could perform expressions on
ORDER BY
.– KaduAmaral
@Bacco thinks it would be worth editing the title of this question to: How to add criteria in order by? I believe that the question would be broader, thus covering a larger audience.
– Marconi
@Marconi tried to reach a consensus between his suggestion and the original title. It didn’t get so short, but I think it increases the chance of finding in a survey.
– Bacco
Bacana @Bacco, from time to time I do this in order to search for more readers. thanks!
– Marconi