select a from tb where a>x and b is null
  union all
select b from tb where b>x and b is not null

解决方案 »

  1.   

    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;
      

  2.   

    是這個意思嗎?SELECT A FROM TABLE WHRE A > Xand B is null
    union 
    SELECT B FROM TABLE WHRE B > X and B is not null
      

  3.   

    select nvl(b,a) from table where b>x;
    这样可以吗?
      

  4.   

    decode 是ORACLE的函数,相当于  如果  就  。
      

  5.   

    nvl(b,a)
    的意思是如果b字段为空,就取a字段吗?
      

  6.   

    select NVL(B,A) where NVL(B,A)>x
      

  7.   

    SELECT NVL(B,A) FROM TABLE WHERE NVL(B,A) > X
      

  8.   

    这个效率高些:
    select nvl(b,a) from table where decode(b,null,a,b)>x;
      

  9.   

    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;吗?
      

  10.   

    假如有两个字段A,B,如果B为空的话,我想SELECT A FROM TABLE WHRE A > X,如果B不为空的话,我想SELECT B FROM TABLE WHRE B > X,就不关心A了。一条语句如何实现?
    如果我还想在这条语句里面统计字段C的和,放在一条语句里面
    select nvl(b,a),SUM(C) from table where decode(b,null,a,b)>x
    这样写可以吗?
    应该怎么写?
      

  11.   

    后面带上group by nvl(b,a)
      

  12.   

    我不想group
    我想每条都取