Is there a way in kdb to use functions in queries. assume I have a table with columns
`red`blue`green`yellow`white`purple
which contain either values 0 or 1. Instead of querying
select where ((red=1) or (green=1))
can I use a function like
isRG:{((select green from x)=1) or ((select red from x)=1)}
to filter a select? I can do
f:[select from t]
and it returns a column with true and false, but I cant figure out how to do something along the lines of
select from t where f[select from t]
to get all entries where f(x) is true
Yes - although you don't need to pass the entire table into the function, just the relevant columns:
The key principles to keep in mind when using a function in a select where clause is: