Reputation: 519
I have a table below:
tab:([]a:(`$"1-01";`2;`$"3-01";`4;`$"5-01";`6);source:`a`a`b`b`a`b)
a source
-----------
1-01 a
2 a
3-01 b
4 b
5-01 a
6 b
I would like to change the 1-01 and 5-01 back to 1 but not for 3-01 depending on the source. I wrote the code below:
`$({ssr[string x;"-01";""]}each tab[`a])
by doing this I can put this back to a column, but this is not what I want. I also did the following:
`$({ssr[string x;"-01";""]}each tab[`a] where source=`a)
but after doing this I do not know how to put it back to the table. Then I thought of using execution control: but not sure how i should code it. I have it half way done and it does not really work:
?[tab[`source] = `a;`$({ssr[string tab[`a];"-01";""]});tab[`a]]
Upvotes: 0
Views: 1894
Reputation: 13572
An "update" seems to be what you need:
q)update `$ssr[;"-01";""] each string a from tab where source=`a
a source
-----------
1 a
2 a
3-01 b
4 b
5 a
6 b
Upvotes: 2