select S.*,
(select S1.location from services S1 where S1.main = S.main and (S1.list is null or S1.list = '')) head_index
from services S
order by head_index, S.list is null or S.list = '' desc, S.location is null or S.location = '' desc, S.location
Ну, тогда вопрос, какую выборку вы ходите получить от запроса при таких условиях?