How to apply maximum function for each row in KDB?

I want all the values ​​in column x be at least 0.5, so I:

 update x:max (x 0.5) from myTable 

But this gives an error (in Studio For KDB + ):

 An error occurred during execution of the query. The server sent the response: type Studio Hint: Possibly this error refers to wrong type, eg `a+1 

What's wrong?

+6
source share
3 answers

You can try to use |

 q)update x|0.5 from myTable 
+8
source

It should work. It worked for me. This is the query I used for testing:

 update x:max(x;0.5) from myTable 

- Check semicolon in max. the functions

+3
source

Try kdb vector conditionally its similar to case-if in SQL:

 q)t:([] a:6?.9) q)t a --------- 0.4237094 0.5712045 0.8705158 0.2075746 0.8549775 0.3951729 q)update ?[a<0.5;0.5;a] from t a --------- 0.5 0.5712045 0.8705158 0.5 0.8549775 0.5 q) 
+1
source

All Articles