Reputation: 3195
How can i sort the data in the order that I need, taking into account that I sort inside the group by customer
I.E.
select
customer
, sku
, stuff
, action
, acnumber
, year
from mytable
first I sort by SKU ascending from lowest to highest, then acnumber ascending from lowest to highest, then year from lowest to highest, then for each group scu + acnumber + year I have to sort the Customer variable, where the first, the Latin letters increase in ascending order, and then the Cyrillic symbols
an example of how this should look like I gave
for example, for 2017 year, and for acnumber number 2 and 13-sku, Customer must be ordered in this way
Z
А
Б
В
how to sort it? now I have a Cyrillic symbols at first
А
Б
В
Z
taking into account the fact that this must be done for each group scu + acnumber + year
i.e it is necessary that the order was like this
Customer SKU stuff action acnumber year
1 z 12 20 30 1 2017
2 z 13 20 30 1 2017
3 А 13 20 30 1 2017
4 Б 14 20 30 1 2017
5 Z 13 20 30 2 2017
6 А 13 20 30 2 2017
7 Б 13 20 30 2 2017
8 В 13 20 30 2 2017
Upvotes: 0
Views: 225
Reputation: 1269953
I think you want:
order by acnumber,
(case when customer like '[a-zA-Z]%' then 1 else 2 end),
customer
Upvotes: 2