sql - 在两个表中查询 Postgres
解决方案
在 Postgres 中,您可以使用它distinct on
来解决这个 top-1-per-group 问题:
select distinct on(a.inst_code)
a.inst_code,
b.inst_name,
a.version,
a.status,
a.date
from tablea a
inner join table b on b.inst_code = a.inst_code
order by a.inst_code, a.version desc, a.date desc
推荐阅读
- c# - 使用正则表达式解析多行控制台输出
- ios - 如何在 iOS 的 StickerPipe 视图中隐藏“+”按钮?
- java - 修剪只有空格的字符串时会发生什么?
- python - 安装错误嗯
- ruby-on-rails - 花时间加载 pdf + rails2?
- c# - How can I parse very nested json by newton in C#?
- css - 有没有办法像在编辑器中一样将相同的样式应用于不同的 XML 标签/突出显示语法?
- php - 使用html按钮从另一个文件中的类调用php函数
- android - android设置中的react-native-firebase依赖问题
- scala - add elements in scala lists