Select *
FROM SOME_TABLE
where Variable_1 in (1,2,3,4)
and not (Variable_1 in (1) and Variable_2<75000)
所以我希望变量1,2,3,4包含在输出中,但所有变量_1 = 1和<75000都排除在外。 我只能排除ALL Variable_1 = 1和ALL Variable_2 <75000。我只需要将两个变量组合在一起排除,而分开保存!
我使用netezza SQL。
答案 0 :(得分:0)
使用不存在:
Select *
FROM SOME_TABLE A
where Variable_1 in (1,2,3,4)
and not EXISTS
(
SELECT 1 FROM SOME_TABLE B WHERE
A.PRIMARYKEY = B.PRIMARYKEY
AND Variable_1 in (1)
and Variable_2<75000
);