选择一列中不包含null的行



我只想在Credit中的所有行都已填充时选择客户端。从表中,我只想看到客户端1、客户端3、客户端4和客户端5的行。

我试过这个:

SELECT *
FROM table
WHERE EXISTS (SELECT client FROM table WHERE [CREDIT] = 'cred')

但不起作用。。。

谢谢!

信用
客户
1CRED
1CRED
1CRED
1CRED
1CRED
2
2CRED
2CRED
3CRED
3CRED
3CRED
3CRED
4CRED
4CRED
5CRED
6
6
6
6CRED
6CRED

您需要一个self-(antisemi(连接:

SELECT t.*
FROM table t
WHERE NOT EXISTS (SELECT 1
FROM table t2
WHERE t1.client = t2.client
AND t2.credit IS NULL)
SELECT client, count(credit)  FROM t
group by client
having count(client) = sum(case when credit is null then 0 else 1 end)

最新更新