例如:
A:null,1,2
B:null,a,b
code:10,20,30
msg:對,錯,空
將上面這些進行排列組合,但需要設定規則。
例如:
null,a,20,空(當A取null,對應code需要是20,對應msg需要是空)
null,null,20,空(當A和B都取null時,會根據A的取值進行判斷)
1,null,30,錯(當B取null時,對應code需要是30,對應msg需要是錯)
1,a,10,對(當A和B都有值的時候,對應code需要是10,對應msg需要是對)
這些只是排列組合的幾個例子,需要將上面的元素全部按照規則,排列組合輸出,最好可以再輸出到excel里面。方法沒有限制,有沒有大佬可以提供一個思路,或者有現成的例子讓我借鑒一下,萬分感謝。
uj5u.com熱心網友回復:
select t1.col a,
t2.col b,
case when t1.col is null then 20
when t2.col is null then 30
when t1.col is not null and t2.col is not null then 10
else 20 end code,
case when t1.col is null then '空'
when t2.col is null then '錯'
when t1.col is not null and t2.col is not null then '對'
else '空' end msg
from (
select null col from dual
union all select '1' col from dual
union all select '2' col from dual) t1,
(
select null col from dual
union all select 'a' col from dual
union all select 'b' col from dual) t2
;
uj5u.com熱心網友回復:
感謝感謝
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/225081.html
標籤:Java相關
