KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Window Join w/ Multiple Symbols

  • Window Join w/ Multiple Symbols

    Posted by Laura on April 5, 2022 at 12:00 am

    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!

    Laura replied 9 months, 1 week ago 2 Members · 4 Replies
  • 4 Replies
  • matt_moore

    Member
    April 5, 2022 at 12:00 am
    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
  • matt_moore

    Member
    April 5, 2022 at 12:00 am

    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.

  • Laura

    Administrator
    April 5, 2022 at 12:00 am

    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?

  • Laura

    Administrator
    April 5, 2022 at 12:00 am

    that was it, thanks!

Log in to reply.