select * from Geniuses
order by
-- First, order by your set order...
case FullName
when 'Charles Babbage' then 1
when 'Albert Einstein' then 2
when 'Adrien-Marie Legendre' then 3
when 'Niels Henrik Abel' then 4
else 5
end,
-- Then do a secondary sort on FullName for everyone else.
FullName
EDIT:
Я видел ваш комментарий о том, что он настраивается каждым пользователем. В этом случае вам понадобится таблица FavoriteGeniuses
, которая отслеживает, какой пользователь предпочитает какую Geniuses
, а затем имеет порядок сортировки, указанный в этой таблице:
select *
from
Geniuses g left join
FavoriteGeniuses fg
ON fg.GeniusID = g.GeniusID
AND fg.UserID = @UserID
order by
-- The higher the number, the first up on the list.
-- This will put the NULLs (unspecified) below the favorites.
fg.SortPriority DESC,
f.FullName