如何从表中选择所有记录,但col-B中值为-43的空值除外?
COLUMN-A COLUMN-B
--------------------
N 433
N 431
Y 431
431
431
Y 431
N 431
N 520
520
N 304
390
N 410
433
期望的输出:
COLUMN-A COLUMN-B
--------------------
N 433
N 431
Y 431
Y 431
N 431
N 520
520
N 304
390
N 410
433
答案 0 :(得分:0)
(select * from table where column_b ! - 431 )
union
(select * from table where column_b = 431 and column_a is not null);
答案 1 :(得分:0)
你可以写:
SELECT *
FROM table
WHERE column_b <> 431
OR column_a IS NOT NULL;
答案 2 :(得分:0)
试试这个: -
Select * from
(select * from table where column_b = 431 and column_a is not null
union all
select * from table where column_b <> 431) A