I know how to selectsort one category separately and how to selectsort all categories according to ASCor DESC. My question is how to selectcategorize all categories in such a way that, for example, the fifth category comes first and the others come first?
select
ASC
DESC
Assuming that the fifth category simply means that you want to prefer a certain category, for example Category-Name, you can use CASE:
Category-Name
CASE
SELECT t.* FROM dbo.Tablename t ORDER BY CASE WHEN t.Category = 'Category-Name' THEN 0 ELSE 1 END ASC, Category ASC
You can use the function field()
field()
select * from categories order by field(id,5) desc,id
or
select * from categories order by id= 5 desc,id
Source: https://habr.com/ru/post/1584889/More articles:As I understand it, this is logging in or logging out in facebook sdk 4.0.1 - androidJavaScript throws: "not a function" when I pass an object as an argument - javascriptMultiplication of the next number - c ++How to flush a buffer using ZPL II [Zebra GK420d] - zpl-iiAnalysis activity is not displayed - androidHow to transfer files through an iPhone personal access point between devices? - iosКак вы добавляете Jeet и Rupture в Stylus-Brunch? - stylusFour (4) routines - sqlGet profile image from Azure Active Directory - c #Is there any way to check if the page came from an external source - c #All Articles