I have a table named "t", with column, "x". It looks as follows:
x
------
1.Fred
2.Joe
3.Hank
.
.
.
500.Mary
I need to take the column and remove everything before the name, for example the "1." before Fred.
I have tried
update $2_'string x from t
but that only works for numbers 1-9 not once I get to the larger numbers. Is there a way to remove the "." and everything before it?
There is one more approach, which helps to cover case when name has '.':
update x:`${(1+x ?\:".")_'x} string x from t
The logic is
x
to string1+x ?\:"."
(1+x ?\:".")_'x
Next model can be used for testing:
//Create table with 100 random names
t: ([] ID: til 100; x: `$(string 1+til 100),'".",'(?[;"abc"] each 1+100?9),'" ",'(?[;"def"] each 1+100?9));
//Replace space with dot for the last 10 names
t: update x: `$ssr[;" ";"."]'[string x] from t where ID>90;
update x:`${(1+x ?\:".")_'x} string x from t
Though using 0:
proposed by @Ryan McCarron is obviously faster. If you sure there are no additional dots, that approach is preferable.