I have a sql statement which I would want to ORDER BY a specific sequence.
SELECT * FROM UserDB ORDER BY [Role]
How can I make it such that the data brought to my GridView table is listed from Admin on the top, follow by User and Guests?
So you want to order by Admin/User/Guest?
Try something like :
SELECT *
FROM UserDB
ORDER BY
CASE Role WHEN 'Admin' THEN 0
WHEN 'User' THEN 1
WHEN 'Guest' THEN 2
END
Does that work for you?
Another option would be to have (or add) a column Sequence to your Role table so you could define the sequence in the table itself - and then just to an ORDER BY Role.Sequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With