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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -