KDB/q count number of rows group by value of a column

Viewed 2090

I have a table like following

tickTime    secid   ltp
1.28E+18    37991   7350
1.28E+18    38596   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    38596   7350
1.28E+18    37986   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    37981   7350
1.28E+18    45402   7350
1.28E+18    45402   7350
1.28E+18    37981   7350

How can I do a count of no of rows for each secid in Q ? Something like select count(*) group by secid in sql?

1 Answers
select count i by secid from tablename

This is how you create a count column. It will return the secid's and the number of times they occur in a table. Could rename the count column to "counts" as follows:

select counts:count i by secid from tablename
Related