我必须按某列整理我的数据,以便首先出现某个特定值。所以对于这样的查询......
SELECT rtrim(taskid) into v_taskid FROM tasks
where
/* some where clausers */
and rownum = 1
...我基于它case when
,但困扰我的是我现在拥有的三个嵌套选择:
SELECT rtrim(taskid) into v_taskid FROM tasks where taskid in (
select taskid from (
select taskid,
case when taskuser like '%myuser%'
then 0
else 100
end as ordervalue
FROM tasks
where
/* some where clausers */
order by ordervalue
)
)
and rownum = 1
性能方面,我认为这应该不是问题,但它看起来有点像意大利面条......有什么办法可以放入case-when
条款中where
吗?