查询结果的顺序
select * from X
where X.a like '11%'
or X.a like '12%'
or X.a like '13%'
or ……
查询结果是:
12
13
11
我想让查询出来的结果是按照我select语句中like的先后顺序显示,也就是
11
12
13
为什么用上面的select不行呢?
------解决方案--------------------select * from X
where X.a like '11%'
or X.a like '12%'
or X.a like '13%'
or ……
order by a
------解决方案--------------------select a from (
select a,rownum rn from X
where X.a like '11%'
union
select a,rownum+1 rn from X
where X.a like '12%'
select a,rownum+2 rn from X
where X.a like '13%' )
order by rn
------解决方案--------------------select a from (
select a,rownum rn from X
where X.a like '11%'
union
select a,rownum+1 rn from X
where X.a like '12%'
union
.
.
.
union
select a,rownum+1 rn from X
where X.a like 'XX%'
------解决方案--------------------顶顶
------解决方案--------------------select a from (
select a,rownum rn from X
where X.a like '11%'
union
select a,rownum+1 rn from X
where X.a like '12%'
union
.
.
.
union
select a,rownum+1 rn from X
where X.a like 'XX%')