Running Entry Count

Hey Qbies, 

I have a table containing for multiple symbols that I’m looking to count rows…

For example:

symbol | symbol count | dataset count

aapl | 1 | 1

aapl| 2 | 2

goog| 1 | 3 

 

Basically, I want to get identify the row count by symbol and then by dataset. I know that I can just grab “i” to get the rowcount for the dataset, but I’m having trouble pulling a symbol count

 

Thanks! 

sums i=i by sym 

did the trick

Not entirely clear what you’re looking for here. If you want to produce a 1…N 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 it’s 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