位置:首页 > 网络编程 > 数据库
点击展开栏目简介
数据库技术,mysql,oracle

oracle:排序时对字段特定值执行置顶或固底(指定某个数据排在第一位或最后一页)

分享到: 微信 新浪微博 更多
select * from f_area ar where ar.status=1 and ar.parent_id=-1
ORDER BY DECODE(ar.area_code,'3101','1',ar.area_code)

---指定3101的排在第一位

select userid from tb
order by decode(userid,'f',null,userid) nulls first
--排序的时候如果是f的话转换成null 其他的不变 
--nulls first表示null排在前面 nulls last 表示null排在后面
--------------------- 

上篇:mysql:like模糊查询的优化

下篇:oracle:group by语句必须要包含select和order by里的字段问题处理

发表评论 ​共有​条评论
  • 匿名发表