sql - 最大时间戳记录
问题描述
我有 2 张桌子想要加入。
我在 CTE 中使用,在我加入他们之后。
我想从 Table2 中为每个 student_id 选择最新记录(因此对于 Table1 中的每条记录,我在 table2 中只有一条记录可以加入)。连接是通过左连接到 table1。
我怎么能成功?我尝试了很多方法并没有找到解决方案。
主表-Table1 Stundet_id 类注释
表2
teacher_id Studnet_id teacher_name Recorded_timestamp
解决方案
我附上了一张解释这一点的照片
推荐阅读
- ngrok - 如何使用 ngrok 生成带有 SSL/TLS 的修复 url
- javascript - NPM:如何添加不为包消费者运行的“安装后”挂钩?
- powershell - Out-Gridview 快速过滤器搜索不允许空格
- python - 我可以在 python 的图形模块中使用 RGB 吗?
- javascript - JavaScript 中的循环和计数
- postgresql - Is there a way that I can access saved entities within a transaction in TypeORM?
- python - 如何在python的dict继承中使用items()和values()强制调用__getitem__
- ios - iOS 14 通知不显示图像
- node.js - ZeroMQ 重传 pub-sub 模型
- selenium-webdriver - 树莓派 4:selenium.common.exceptions.SessionNotCreatedException:消息:无法找到匹配的功能集