And where should i put this function ? Because i was trying to put it everywhere, still doesnt work..
Should i put it smth like:
SELECT * FROM Customers ORDER BY CASEWHEN CustomerName LIKE '%a%' THEN 1 ORDER BY LENGHT(CustomerName)WHEN CustomerName LIKE '%b%' THEN 2 ORDER BY LENGHT(CustomerName)ELSE 3 ORDER BY LENGHT(CustomerName)END
I mean, if i have data like:
"house"
"cup"
"apartament"
"yard"
"bell"
"ben"
and in my order (without sorting by lenght) it appears like:
apartament, yard, bell, ben, house, cup.
if i put selected data in sectors, by which case it was selected, it would look like this:
(1 order): apartament, yard, ball
(2 order): bell, ben
(3 order): house, cup
and i need to sort them by length in DESC order, so it should look like this:
(1 order): ball, yard, apartament.
(2 order): ben, bell.
(3 order): cup, house.
so all selected data should appear like:
ball, yard, apartament, ben, bell, cup, house.
how to do that with case and order by length?