mkoon
1
https://learninghub.kx.com/forums/topic/select-with-ssr-function-2
need some help with a query.
I am trying to select a column and apply a function. This function would ssr an existing column.
select {[x](ssr[x;".C";""])} orderID, cancelTime from t
Sample Table
orderID cancelTime
----------------------------------------------------
"00193932455ORSL1.4.C" 2023.06.13D14:42:12.296856000
"00193935456ORSL1.1.C" 2023.06.13D13:56:47.006888000
"00193946420ORSL1.1.C" 2023.06.13D14:41:40.911418000
"00194008439ORSL1.5.C" 2023.06.13D17:14:06.267606000
https://code.kx.com/q/ref/each/
Use each:
q)select {[x]ssr[x;".C";""]} each orderID, cancelTime from t
https://code.kx.com/q/basics/application/#projection
Neater with projection:
select ssr[;".C";""] each orderID, cancelTime from t
https://code.kx.com/q/ref/drop/
If you know .C is always at the end it's much better to use drop _ rather than ssr as ssr is compute intensive
select {-2_ x} each orderID, cancelTime from t
https://code.kx.com/q/ref/maps/#each-left-and-each-right
each-right /: is neater
q)select -2_/:orderID, cancelTime from t
mkoon
3
thank you, much appreciated.