Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear all,
i have a table like this:
Name |
Mark |
Julia |
Mike |
John |
John |
John |
i want to rename all duplicated in order to have only distinct values to obtain
Name |
Mark |
Julia |
Mike |
John |
John 2 |
John 3 |
How to do this?
thanks
Try like:
Load *,
Name& If(AutoNumber(RowNo(),Name)>1,AutoNumber(RowNo(), Name)) as NewName
Inline [
Name
Mark
Julia
Mike
John
John
John]
One solution:
Data:
LOAD * INLINE [
Name
Mark
Julia
Mike
John
John
John
];
Tmp:
noconcatenate
load *,if(rowno()=1,1,if(peek(Name)=Name,peek(n)+1,1)) as n resident Data order by Name;
drop table Data;
Final:
noconcatenate
load if(n=1,Name,Name&n) as Name resident Tmp;
drop table Tmp;
output :
Try like:
Load *,
Name& If(AutoNumber(RowNo(),Name)>1,AutoNumber(RowNo(), Name)) as NewName
Inline [
Name
Mark
Julia
Mike
John
John
John]
Why can'y you append rowNo() with Name column:
Name&' '&RowNo() as distinctName