KX Community

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

Home Forums kdb+ need help on a query

  • need help on a query

    Posted by fav_pa on June 10, 2024 at 10:08 am

    i have this simple table:

    timestamp timeWin   
    --------------------
    1         1 2 3    
    2         1 2 4 5 
    3         3 1 1 3 5

    my goal is to modify timeWin column so that on each row, the list doesn’t contain the timestamp, i.e. get that :

    timestamp timeWin   
    --------------------
    1         2 3    
    2         1 4 5 
    3         1 1 5

    I know it’s basic but i really can’t figure it out. Thank you for your help

    fav_pa replied 1 week, 2 days ago 3 Members · 3 Replies
  • 3 Replies
  • unterrainer_ale

    Member
    June 10, 2024 at 10:29 am

    This should do

    129200

    q)t:([] timestamp:1 2 3;timeWin:(1 2 3;1 2 4 5;3 1 1 3 5))

    q)update timeWin:timeWin except’timestamp from t

    timestamp timeWin

    —————–

    1 2 3

    2 1 4 5

    3 1 1 5

  • rocuinneagain

    Member
    June 10, 2024 at 10:33 am
    q)tab:([] timestamp:1 2 3;timeWin:(1 2 3;1 2 4 5;3 1 1 3 5))
    q)tab
    timestamp timeWin
    -------------------
    1 1 2 3
    2 1 2 4 5
    3 3 1 1 3 5
    q)update timeWin:except'[timeWin;timestamp] from tab
    timestamp timeWin
    -----------------
    1 2 3
    2 1 4 5
    3 1 1 5
    • fav_pa

      Member
      June 11, 2024 at 9:38 am

      great thank you so much

Log in to reply.