问题描述
Select *
FROM SOME_TABLE
where Variable_1 in (1,2,3,4)
and not (Variable_1 in (1) and Variable_2<75000)
所以我希望变量1,4包含在输出中,但所有变量_1 = 1和
我使用netezza sql。
解决方法
使用不存在:
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
);