cancel
Showing results for 
Search instead for 
Did you mean: 

Running Entry Count

planefan
Contributor

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! 

1 ACCEPTED SOLUTION

planefan
Contributor

sums i=i by sym 

did the trick

View solution in original post

2 REPLIES 2

planefan
Contributor

sums i=i by sym 

did the trick

SJT
Valued Contributor
Valued Contributor

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