mysql - Order by descending then ascending same column -


how sql order same column differently depending on conditions? in example below, if n/s n, order distfromc desc, if not order distfromc asc, appear table below.

name  n/s  distfromc bh    n    2 fv    n    1 c     c    0 rs    s    1 mtn   s    2 

select tablename.* tablename order   `n/s` = 'n' desc,   case when `n/s` = 'n' distfromc end desc,   case when `n/s` != 'n' distfromc end asc 

please see fiddle here.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -