码迷,mamicode.com
首页 > 数据库 > 详细

oracle语句使用经验

时间:2018-04-25 10:54:15      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:Oracle

SELECT
FROM (SELECT A1.
,ROWNUM RN
FROM (SELECT H.*
FROM TBC_ADOWNBLK_HIST H
WHERE 1 = 1
ORDER BY adownblkid ASC) A1
WHERE ROWNUM <= 10)
WHERE RN >= 1
想排序必须按这种写法

--根据不同字典值去加‘前缀’
方法一
select CASE
WHEN dict_code = ‘YYPZ‘ THEN ‘0‘ || CODE
ELSE ‘1‘ || CODE end as code,
name as name
from MSTB_BDS_DATA
where (dict_code = ‘VOICEOTHERTYPE‘ or dict_code = ‘YYPZ‘)
and record_state = ‘1‘
方法二
(select ‘0‘||CODE code,NAME from MSTB_BDS_DATA d where d.dict_code=‘YYPZ‘ and record_state = ‘1‘ ) union all (select ‘1‘||CODE code,NAME from MSTB_BDS_DATA d where d.dict_code=‘VOICEOTHERTYPE‘ and record_state = ‘1‘)

oracle语句使用经验

标签:Oracle

原文地址:http://blog.51cto.com/hebinteng/2107570

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!