2016-10-18 3 views
0

私はこの(木次DESC出力)のようなDESC出力を行うことができますどのようにMatherialパスツリー-出力

b 
b1 
b11 
c  
c1 
d  
e  
f  
g 
g1 

のようなmatherialパスを持つ列がありますか?あなたは、ASCII機能を使用する必要が

g 
g1 
f 
e 
d 
c 
c1 
b 
b1 
b11 

答えて

0

create table t(col varchar(10)); 
insert into t 
select 'b' union all 
select 'b1' union all 
select 'b11' union all 
select 'c' union all 
select 'c1' union all 
select 'd' union all  
select 'e' union all  
select 'f' union all  
select 'g' union all 
select 'g1'; 

select * from t 
order by 
ascii(col) desc, 
length(col) ; 

結果は

col 
g 
g1 
f 
e 
d 
c 
c1 
b 
b1 
b11 

SQLFiddleリンクhttp://sqlfiddle.com/#!9/eaf954/4

です