

mchbrn-q
Forum Replies Created
-
Yeah that’s interesting. And since “a”, the select phrase, can take a parse tree, you could translate the functional simple exec
q)?[tab;til 10;(last;`c2)] 19
to the functional exec
q)exec last c2 from tab 19 q)parse "exec last c2 from tab" ? `tab () () ,(last;`c2) q)?[tab;();();(last;`c2)] 19
I can’t find any examples online of standard qSQL simple execs though? I don’t know if it exists because https://code.kx.com/q/ref/exec/#syntax doesn’t reference any phrases that allows for indexes . . .
-
It’s not entirely clear what you are trying to achieve when you only supply two broken queries.
Adding where to your query was a suggestion based on the return type being a list of booleans. Using where with your query returns the indexes of tab where c2>16. This could then be fed back into the table to return the desired data.
q)tab where ?[tab;til 10;(>;`c2;16)] c1 c2 ----- 7 17 8 18 9 19
You’ll need to use semicolons to form a valid parse tree as shown here https://code.kx.com/q/wp/parse-trees/#eval-and-value like you have used in your first query but not your second.
This was all based off the assumption that you were attempting to use simple execs in functional form https://code.kx.com/q/basics/funsql/#simple-exec
-
Would just like to add https://code.kx.com/q/basics/funsql/#simple-exec
Judging by the number of args in OP’s functional query, a simple exec takes table name, list of indexes and parse tree.
-
Simply prepend where to the former
q)where ?[tab;til 10;(>;`c2;16)] 7 8 9
and insert a semicolon to the latter
q)?[tab;til 10;(last;`c2)] 19