KX Community

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

Home Forums kdb+ Running Entry Count Re: Running Entry Count

  • Laura

    Administrator
    April 7, 2022 at 12:00 am

    Not entirely clear what youre looking for here. If you want to produce a 1N list for each symbol you can use til and avoid the sums and comparisons:

     

    q)select 1+til count i by sym from t 
    sym | x 
    ----| --------------- 
    aapl| 1 2 3 4 5 
    goog| 1 2 3 4 5 6 7 8 
    msft| 1 2 3 4 5 6 7

     

    but its hard to see a use for the lists. Perhaps you simply want to count rows for each symbol?

    q)exec count i by sym from t 
    aapl| 5 
    goog| 8 
    msft| 7 
    q)ts:1000 select sums i=i by sym from t 
    4 10720 
    q)ts:1000 exec count i by sym from t 
    1 9584