现在的位置: 首页 > 综合 > 正文

order by case when then end

2012年03月17日 ⁄ 综合 ⁄ 共 193字 ⁄ 字号 评论关闭

 

是按条件来排序,举个简单的例子:select   a,b,c   from   tab   order   by   case   表达式   when   条件1   then   a   when   条件2   then   b   else   c   end;     
这个select语句就是当表达式满足条件1的时候就按a来排序,满足条件2的时候就按b排序,否则就按c排序

抱歉!评论已关闭.