select a.id,nvl(a.status,'不在用') status from ( select id,'在用' status from user where id>0 and id<5 ) a, ( select rownum id from all_tables where rownum<5 ) b where b.id=a.id(+);
select a.id,nvl(a.status,'不在用') status from ( select id,'在用' status from user where id>X and id<Y ) a, ( select rownum+X id from all_tables where rownum<Y ) b where b.id=a.id(+);当条件id>0 and id<5变化为id>X and id<Y
select a.id,nvl(a.status,'不在用') status from ( select id,'在用' status from user where id>X and id<Y ) a, ( select rownum+X id from all_tables where rownum<Y-X ) b where b.id=a.id(+);改一下
user表(id number,name varchar2(20))
输入id的起号和结束号,查询那些id已经在用,那些id 不在用。to :飘
我是说用一个sql语句写出。
等。。
(
select id,'在用' status from user where id>0 and id<5
) a,
(
select rownum id from all_tables where rownum<5
) b
where b.id=a.id(+);
(
select id,'在用' status from user where id>X and id<Y
) a,
(
select rownum+X id from all_tables where rownum<Y
) b
where b.id=a.id(+);当条件id>0 and id<5变化为id>X and id<Y
(
select id,'在用' status from user where id>X and id<Y
) a,
(
select rownum+X id from all_tables where rownum<Y-X
) b
where b.id=a.id(+);改一下