Home › Forums › kdb+ › select with combinational conditions › Re: select with combinational conditions
-
Assuming your initial table can grow to a large size, probably best to only query it once to get the dates and symbols you’re interested in:
q)l:((2023.05.20;`a`b);(2023.05.19;enlist `b);(2023.05.18;`c`d`a);(2023.05.17;`d`a)); q)tab:flip `date`data!(2023.05.20 2023.05.20 2023.05.20 2023.05.19 2023.05.19 2023.05.19;`a`c`b`b`b`c); q)subset:select from tab where date in l[;0],data in raze l[;1]; q)raze{select from y where date=x[0],data in x[1]}[;subset]each l date data --------------- 2023.05.20 a 2023.05.20 b 2023.05.19 b 2023.05.19 b
There’s probably a more efficient way but this should do it