This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 有没有别较有效的办法, 我有一个表,其中一个字段包含下列数字,如何变成连续的数,如:1,2,3,4... 谢谢
1, 3,6,7 , 9 ,11, 16,17, 19, 23, 27....
-waiting(OK);
2006-7-28
(#3108799@0)
-
column may contain duplciated numbers., i.e.1,3,3,4,,7, 9,10, 11, 16,17,20,22
need to be changed to:
1,2,2,3,4,5,6,7...
-waiting(OK);
2006-7-28
{79}
(#3108816@0)
-
create a temprary table t2 with two fields: id (auto increased) and f1; insert into t2 (f1 ) select distinct f1 from t1 order by f1; update t1 set t1.f1=t2.id where t1.f1=t2.f1?
-holdon(again);
2006-7-28
(#3108866@0)
-
thanks
-waiting(OK);
2006-7-28
(#3108933@0)
-
1. create a new table TABLE_NEW with same columns as existing table TABLE_OLD, add a new column as IDENTITY column,
2. INSERT INTO TABLE_NEW Select * from TABLE_OLDassume that TABLE_OLD has in order of 1, 3,6,7 , 9 ,11, 16,17
-mystery(Lost In North);
2006-7-28
{61}
(#3108953@0)
-
rownum will do, example:create table b (col1 number);
begin for i in 1..10 loop
insert into b values (i);
insert into b values (i);
end loop;
end;
/
select rownum, COL1 from ( select distinct col1 "COL1" from b);
rownum is the increamental number, col1 would be the column for the random number, including duplicates...
-dbaexpert(DBA);
2006-8-1
{311}
(#3115269@0)
-
how big is the table? if it is less than 3000 rows, u can copy the column to Excel. use formula to derive the second column to fit your requirment. the forumla is not diffciult to imagine.
-647i(流浪的步行万里);
2006-8-1
(#3117338@0)