如何使用PostgreSQL查找引荐最多且至少拥有三双蓝色鞋子的用户?
table 1 - users
name (matches shoes.owner_name)
referred_by (foreign keyed to users.name)
table 2 - shoes
owner_name (matches persons.name)
shoe_name
shoe_color
到目前为止,我拥有的是单独的查询,它们返回上面我想要的内容:
(SELECT count(*) as shoe_count
FROM shoes
GROUP BY owner_name
WHERE shoe_color = “blue”
AND shoe_count>3) most_shoes
INNER JOIN
(SELECT count(*) as referral_count
FROM users
GROUP BY referred_by
) most_referrals
ORDER BY referral_count DESC
LIMIT 1
答案 0 :(得分:1)
两个子查询似乎很可行。它们看起来像:
$ python -m pip install --upgrade firefox
#ERROR:
Could not find a version that satisfies the requirement firefox (from
versions: )
No matching distribution found for firefox
$ python -m pip install firefoxCollecting firefox
#ERROR:
Could not find a version that satisfies the requirement firefox (from
versions: )
No matching distribution found for firefox
$ sudo pip install --upgrade firefox
#ERROR:
Could not find any downloads that satisfy the requirement firefox
Cleaning up...
No distributions at all found for firefox
Storing debug log for failure in /home/arvind/.pip/pip.log