Hi Aneela,

If you need to count all the records (without grouping by employee_id) you
will have to do something similar to the following. (This is just one way
of addressing your requirement)

(define an in-memory table to store count)

define table CountTable (count long);

from inputStream#window.timeBatch(2 min)
select count() as count
insert into CountTable;

from inputStream#window.timeBatch(4 min)
select employee_id
group by employee_id
insert into TempStream;

from TempStream as t join CountTable as c
select t.employee_id, c.count
insert into OutputStream;


The execution plan would work if you have prior knowledge that all the
input events would arrive within 2 minutes. In the second query a larger
batch time is used to ensure that, the count is already written to table
CountTable, by the time events start being sent to TempStream.

Thank you
Charini



On Mon, Aug 29, 2016 at 11:59 PM, Aneela Safdar <[email protected]> wrote:

> Hi,
>
> How can I achieve this sql in siddhi query languge:
>
> select employee_id, (select count(*) from employees)
> from employees
>
> I want just a two columns of a stream, one legitimate and other is count
> of all records.
>
> Thanks,
>
> Regards,
> Aneela Safdar
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Charini Vimansha Nanayakkara*
Software Engineer at WSO2

Mobile: 0714126293
E-mail: [email protected]
Blog: http://www.charini.me/

<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to