cancel
Showing results for 
Search instead for 
Did you mean: 

Window Join w/ Multiple Symbols

planefan
Contributor

Whats good, Qbies.

I have 2 tables I'm trying to put together with a window join using `sym`time columns. 

The output table comes through fine, but I go through the data and it's clearly mixing results from different symbols. What gives? 

I've checked datatypes and everything seems in order, with `sym amounting to a "s" type in both tables.

Any help greatly appreciated!  

1 ACCEPTED SOLUTION

matt_moore
New Contributor III
update `p#sym from q 
/ or
@[q;`sym;`p#]

/ may need to sort first if it isn't already 
update `p#sym from `sym`time xasc q

View solution in original post

4 REPLIES 4

matt_moore
New Contributor III

wj requires parted attribute on sym column of 2nd table:

t and q are simple tables to be joined (q should be sorted `sym`time with `p# on sym)
Window join | Reference | kdb+ and q documentation - Kdb+ and q documentation (kx.com)
I've found when doing this with more than one sym column you need to join them together and sort/apply part to a combined column.

Also depending on what you are doing, an aj at the start and end of your window can be faster but depends on what you are trying to do. 

Yeah, I took a look at aj but ultimately wj just better suites my needs. 

So I've got the tables sorted ``sym ``time but seem to be missing on the `p# part (pun maybe intended). 

How does one `p# a column in a table properly? 

matt_moore
New Contributor III
update `p#sym from q 
/ or
@[q;`sym;`p#]

/ may need to sort first if it isn't already 
update `p#sym from `sym`time xasc q

that was it, thanks!