(sql teradata)在一列中具有重复值,达到下面显示的输出
原始表
列1 | 第2列 | 第3列 |
---|---|---|
1 | 2019-03-09 13:03:59.000 | 2019-03-09 13:33:12.000 |
2 | 2019-03-09 13:33:33: | 12.000 2019-03-09-09 13:33:33:33:19.000 |
2 | 2019-03-09 13:33:19.000 | 2019-08-09 01:07:21.000 |
输出(从第一个重复行中获取第2列的值,第二副重复行的列3值):
列1 | 列2 | 第3列 |
---|---|---|
1 | 2019-03-09 13:03:59.000 | 2019-03-09 13:33:12.000 |
2 | 2019-03-09 13:33:33:12.000 | 2019-08-08-09 01:07:21.000:21.000 |
Original Table
Column 1 | Column 2 | Column 3 |
---|---|---|
1 | 2019-03-09 13:03:59.000 | 2019-03-09 13:33:12.000 |
2 | 2019-03-09 13:33:12.000 | 2019-03-09 13:33:19.000 |
2 | 2019-03-09 13:33:19.000 | 2019-08-09 01:07:21.000 |
Output (Getting the value of column 2 from the first duplicate row and the value of column 3 from the second duplicate row):
Column 1 | Column 2 | Column 3 |
---|---|---|
1 | 2019-03-09 13:03:59.000 | 2019-03-09 13:33:12.000 |
2 | 2019-03-09 13:33:12.000 | 2019-08-09 01:07:21.000 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用Row_number()之类的窗口函数来识别您想要在结果集中的行。例如,如果您想根据第2栏和第2列选择最新记录,则可以做类似的事情:
You can use window functions like row_number() to identify the row that you want to be in your result set. For example if you want to pick the latest record based on column2 and column2, you can do something like this: