如何重新排序同一个表中的数据? [英] How do I re-order data in the same table?

查看:42
本文介绍了如何重新排序同一个表中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原样:

ID       Version 
5587138  1
6460704  2
6537612  3
6264608  4

未来:

ID       Version
5587138  1
6264608  2
6460704  3
6537612  4

我必须重新排列 ID 以匹配版本顺序.数据来自同一个表.我目前正在尝试使用 PL/SQL.我真的需要关于这个问题的帮助.谢谢.

I have to re-order the IDs to match the version order. The data is coming from the same table. I am currently trying to use PL/SQL. I really need help on this issue. Thank you.

推荐答案

我的建议是不要更改版本号,因为如果相同的版本是有多个 id 但使用不需要的版本基于rownum

My advice would be don't change the version numbers since if the same version is there for more than one id but use the version no required based on rownum

 SELECT ID,Coldata,rownum version
 FROM ( SELECT ID,Coldata, version FROM TABLE ORDER BY ID,Coldata);

这篇关于如何重新排序同一个表中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆