select * from a ,b where a.up_unit=b.pr_name and a.up_unit='manage'
union
select * from a ,b where a.up_unit=b.pr_name (+) a.up_unit<>'manage'
and a.unit='ss' and a.year='2003' order by a.no asc ,length(b.pr_id) asc,b.pr_id asc
union
select * from a ,b where a.up_unit=b.pr_name (+) a.up_unit<>'manage'
and a.unit='ss' and a.year='2003' order by a.no asc ,length(b.pr_id) asc,b.pr_id asc
length_min设置为length(b.pr_id)的最小值-1
select * from a ,b where a.up_unit=b.pr_name(+) and a.up_unit='manage'
union
select * from a ,b where a.up_unit=b.pr_name (+) a.up_unit<>'manage'
and a.unit='ss' and a.year='2003' order by a.no asc ,length(b.pr_id) asc,b.pr_id asc
to:xmqy110 (氧气) 用 zlqs的方法可以了吗? 因为自己机子比较慢,运行Oracle困难,
服务器上的又不能动,所以如果再不行我再建表试一下
但似乎8 I好像指8.16以上?8.16也是可以的,确信可以用union
我建了两个表
A
NO SUB_UNIT UNIT YEAR
'5', 'manager', 'sss', '2003'
'2', 'hr', 'sss', '2003'
'3', 'develop', 'sss', '2003'
'4', 'cc', 'sss', '2003'
B
PR_ID PR_NAME
'A22', 'hr'
'A23', 'develop'
'A222', 'cc'而且你order by 先制定了a.no它的顺序是第一位的,如果mange的no为100,它还是到不了最上面,
现在的语句是select * from a ,b where a.up_unit=b.pr_name (+) and a.unit='ss' and a.year='2003' order by a.no asc ,length(nvl(b.pr_id,-1)) asc,b.pr_id asc
但还有个问题是a里还有个down_unit,和up_unit一样对应b.pr_name ,也有个manage,我想先排up_unit的顺序,再排down_unit的顺序,能再帮忙一下吗?
NO SUB_UNIT UNIT YEAR PR_ID PR_NAME2 hr sss 2003 A22 hr
3 develop sss 2003 A23 develop
4 cc sss 2003 A222 cc
5 manager sss 2003
你要求这个结果怎样拍
好累:)
我晕,
改order by 顺序试试,最根本的,找sql书看一下,总感觉你问的象外行 he
现在的语句是select * from a ,b where a.up_unit=b.pr_name (+) and a.unit='ss' and a.year='2003' order by a.no asc ,length(nvl(b.pr_id,-1)) asc,b.pr_id asc
问题是a里还有个down_unit,和up_unit一样对应b.pr_name ,也有个manage,我想先排up_unit的顺序,再排down_unit的顺序,能再帮忙一下吗?