每个用户都有一个包含多个记录的能,其中一些记录是空的,
username address
erick
erick
samara
samara New York
denis
denis
expected result:
erick
denis如何编写查询检索表中没有地址值的用户
我试过了,但根本不起作用
“从table_name中选择用户名,其中地址是按用户名分组的”--这也是返回"samara“的,它已经得到了带有地址的记录不是null
发布于 2021-01-21 11:54:30
select username
from table_name
group by username
having sum(case when address is not null then 1 else 0 end) = 0或
having max(address) is null发布于 2021-01-21 11:55:44
你需要这样的东西:
SELECT username
FROM tablename
WHERE username
NOT IN
(
SELECT username FROM tablename
WHERE address IS NOT NULL
)
GROUP BY username;发布于 2021-01-21 11:59:59
你可以这样做:
select username from table
minus
select username from table where address is not nullhttps://stackoverflow.com/questions/65826805
复制相似问题