假设我今天有一堆会员,我有他们的国籍资料
想做一个功能
“筛选出那些会员人数不满10人的国家的会员”
select * from users u1
where 10 > (select count(*) from users u2
where u1.country = u2.country limit 10)
有两个问题
1. 如果“美国”有三个会员,则括号中的命令变成
select ... where "美国" = users.country
这段命令会执行三次吗?还是伟大的的postgres会帮我快取结果,只执行一次?
2. 有没有更好的写法