Attribute value count


#1

Would you know of a scidb query (or nested queries) to group an attribute by the number of occurrence of the attribute value i.e. let say I have a single attribute array of size 5 elements where the attribute has values 1, 1, 1, 2, 2. I want to process the array to return (1,3) and (2,2).

Thanks.


#2

Here is an example array like the one you described:

iquery -aq "build(<val:int32>[i=1:5,5,0], iif(i<4,1,2))"{i} val
{1} 1
{2} 1
{3} 1
{4} 2
{5} 2

And here is a way to get the counts using a redimension aggregate:

iquery -aq " redimension (build(<val:int32>[i=1:5,5,0], iif(i<4,1,2)), <n:uint64 null>[val], count(*) as n)"
{val} n
{1} 3
{2} 2