在 postgresql 中查找辅助键的重复项

问题描述

我对 Postgresql 还很陌生

我正在尝试查找我的辅助键的重复次数,同时仍显示整个表格

我的表 1 是这样的

|studentid|name|major|countryid|
|:-------:|:--:|:----:|:-------------:|
|001|John|finance|1A|
|002|Luc|Marketing|1B|
|003|Thomas|Sales|1A|

我的表 2 是

|countryid|country|
|:-------:|:-----:|
|1A|Australia|
|1B|Spain|

所以每个表当然有很多行

我想要的结果是

|studentid|name|major|country|numberofstudentsfromthiscountry|
|:-------:|:--:|:---:|:-----:|:-----------------------------:|
|001|John|finance|Australia|2|
|002|Luc|Marketing|Spain|1|
|003|Thomas|Sales|Australia|2|

有人可以帮助我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)