KX Community

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

Home Forums kdb+ window join on more than 2 columns ?

  • window join on more than 2 columns ?

    Posted by fav_pa on September 12, 2024 at 4:39 pm

    i have a table that has multiple columns, and among them a datetime, sym, trader_type.
    I would like to do a window join on datetime, sym and trader type
    is it possible?

    unterrainer_ale replied 6 days, 7 hours ago 3 Members · 2 Replies
  • 2 Replies
  • mwoods

    Administrator
    September 13, 2024 at 8:48 am

    Yes it is possible to have more than 2 columns, I extended the example in the Advanced Joins example from the Academy to demonstrate if you want to try it out

    https://learninghub.kx.com/courses/kdb-developer-level-3/lessons/joins-2/

  • unterrainer_ale

    Member
    September 13, 2024 at 8:52 am

    Hi fav_pa,

    yes, a window join wj for several columns is possible. The syntax is

    wj[w;c;t;(q;(f0;c0);(f1;c1))]

    where w is your window, c are the columns you want to match on, in your case this would be sym, date time and trader type. As with the asof join, aj, the time column should be the last in your list, so I assume it’s sym,traderType,datetime (I am avoiding the symbol syntax because of the known UI issue).

    You can read more about wj here https://code.kx.com/q4m3/9_Queries_q-sql/#999-window-join

Log in to reply.