oracle:根据字段数据长度排序

在项目上遇到了需要按照数据长度来排序查询的问题小记

/*
  order by 排序,desc降序,asc升序
*/

select
* from table t order by LENGTH(t.name) desc;
select * from table t order by nvl(length(trim(t.name)),0) desc;
select * from table t order by length(trim(t.name)) desc;

 

posted @ 2021-12-27 10:12  诟笑  阅读(823)  评论(0编辑  收藏  举报