KX Community

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

Home Forums kdb+ Count items from a dynamic list

  • Count items from a dynamic list

    Posted by hzadonis369 on April 30, 2022 at 12:00 am

    Hi, Masters:

    Say I have a list contains dynamic sym variables:

        `a`b`a`b`c`d`c`b`a...

    How can I count each sym and get an output such as:

        `a:4
    
        `b:3
    
        `c:2
    
        `d:1
    hzadonis369 replied 8 months, 1 week ago 1 Member · 1 Reply
  • 1 Reply
  • hzadonis369

    Member
    April 30, 2022 at 12:00 am
    q)lt: `a`b`a`b`c`d`c`b`a
    
    q)group lt
    a| 0 2 8
    b| 1 3 7
    c| 4 6
    d| ,5
    
    q)count each group lt
    a| 3
    b| 3
    c| 2
    d| 1

    Seems not difficult. Any other method?

Log in to reply.