顺带问一下空值在进行比较的时候的问题
with temp as (
select 1 a,2 b ,null c from dual
union all
select 2 a,null b ,1 c from dual
)
select * from temp
A
B
C
1
1
2
null
2
2
null
1
with temp as (
select 1 a,2 b ,null c from dual
union all
select 2 a,null b ,1 c from dual
)
select max(a),max(b),max(c),min(a),min(b),min(c) from temp
MAX(A)
MAX(B)
MAX(C)
MIN(A)
MIN(B)
MIN(C)
1
2
2
1
1
2
1
with temp as (
select 1 a,2 b ,null c from dual
union all
select 2 a,null b ,1 c from dual
)
select greatest(a,b,c),least(a,b,c)from temp
GREATEST(A,B,C)
LEAST(A,B,C)
1
null
null
2
null
null
在用max或min对一列进行比较时,无论取最大还是最小,都不会选择空值,而用greatest或least对一行进行比较时,不论最大还是最小都取的空值?
|