首页 > 解决方案 > 最大时间戳记录

问题描述

我有 2 张桌子想要加入。

我在 CTE 中使用,在我加入他们之后。

我想从 Table2 中为每个 student_id 选择最新记录(因此对于 Table1 中的每条记录,我在 table2 中只有一条记录可以加入)。连接是通过左连接到 table1。

我怎么能成功?我尝试了很多方法并没有找到解决方案。

主表-Table1 Stundet_id 类注释

表2

teacher_id Studnet_id teacher_name Recorded_timestamp

标签: sqlhiveql

解决方案


我附上了一张解释这一点的照片

在此处输入图像描述


推荐阅读