select a from table where a>x and b is null union all select b from table where b>x and b is not null;or select nvl(b,a) from table where decode(b,null,a,b)>x;
是這個意思嗎?SELECT A FROM TABLE WHRE A > Xand B is null union SELECT B FROM TABLE WHRE B > X and B is not null
select nvl(b,a) from table where b>x; 这样可以吗?
decode 是ORACLE的函数,相当于 如果 就 。
nvl(b,a) 的意思是如果b字段为空,就取a字段吗?
select NVL(B,A) where NVL(B,A)>x
SELECT NVL(B,A) FROM TABLE WHERE NVL(B,A) > X
这个效率高些: select nvl(b,a) from table where decode(b,null,a,b)>x;
select nvl(b,a) from table where decode(b,null,a,b)>x; 这条语句里面的 nvl(b,a) 的意思是如果b字段为空,就取a字段吗?我可以select nvl(b,a) as abcd from table where decode(b,null,a,b)>x order by abcd;吗?
union all
select b from table where b>x and b is not null;or
select nvl(b,a) from table where decode(b,null,a,b)>x;
union
SELECT B FROM TABLE WHRE B > X and B is not null
这样可以吗?
的意思是如果b字段为空,就取a字段吗?
select nvl(b,a) from table where decode(b,null,a,b)>x;
这条语句里面的
nvl(b,a)
的意思是如果b字段为空,就取a字段吗?我可以select nvl(b,a) as abcd from table where decode(b,null,a,b)>x order by abcd;吗?
如果我还想在这条语句里面统计字段C的和,放在一条语句里面
select nvl(b,a),SUM(C) from table where decode(b,null,a,b)>x
这样写可以吗?
应该怎么写?
我想每条都取