【发布时间】:2020-03-11 18:50:37
【问题描述】:
我有 2 张桌子,person(email, first_name, last_name, postcode, place_name) 和 location(postcode, place_name)。我试图找到住在只有一个人居住的地方的人。我尝试使用 SELECT COUNT() 但失败了,因为我不知道在这种情况下应该计算什么。
SELECT DISTINCT email,
first_name,
last_name
FROM person
INNER JOIN location USING(postcode,
place_name)
WHERE 1 <=
(SELECT COUNT(?))
【问题讨论】:
-
加入“位置”似乎没有任何意义,因为它不会带来“人”中没有的信息。
标签: sql postgresql select count aggregate-functions