Hi Shashika,

I don't think the count() function will work here. They need a sum of the
values in the countP field. Therefore, they will have to use sum(countP).
So for Initial state HTS, count() will give 2 while sum() will give 4.

I think I have used the wrong field name in my previous email. Sorry about
that.

seshika

On Fri, Nov 14, 2014 at 12:27 PM, Shashika Karunatilaka <shashi...@wso2.com>
wrote:

> HI supun,
> you can use the count function and grouping it by Initial_state(group by
> Initial_state)
>
> Thanks
>
> On Fri, Nov 14, 2014 at 12:23 PM, Seshika Fernando <sesh...@wso2.com>
> wrote:
>
>> Why dont you use the sum(Initial_state) function with a group by
>> Initial_state?
>>
>> On Fri, Nov 14, 2014 at 12:12 PM, Supun Muthutantrige <sup...@wso2.com>
>> wrote:
>>
>>> Hii all,
>>>
>>> There is a mysql table with the following content.
>>>
>>>
>>> The format of the in stream
>>>
>>>        state:HTS
>>>        state:HFS
>>>        state:HTM
>>>        state:HTS
>>>        state:HTL
>>>        state:HFS
>>>        state:MTS
>>>        state:HTS
>>>        state:HTL
>>>        state:MFM
>>>        state:HTS
>>>        state:HFS​
>>>
>>>
>>> The following siddhi query is used to populate the above table.
>>>
>>>
>>> ----------------------------------------------------------------------------------------------------------------------
>>>
>>> define table MarkovModel (State_Transition string, Initial_state string,
>>> countP double) from ('datasource.name'='FD_ToolBox_DB', 
>>> 'database.name'='FDtoolbox',
>>> 'table.name'='MarkovModel');
>>>
>>> from every a = inStream -> b = inStream
>>> select a.Event as initialState, b.Event as transState,
>>> concat(a.Event,b.Event) as StateTransition
>>> insert into forCalculation;
>>>
>>> from forCalculation[((StateTransition!=MarkovModel.State_Transition)
>>> in MarkovModel)]
>>> select StateTransition, initialState, 1.0 as stateTrans_count
>>> insert into insertIntoModel;
>>>
>>>
>>> from forCalculation[((StateTransition==MarkovModel.State_Transition) in
>>> MarkovModel)]#window.length(1) join MarkovModel
>>> on forCalculation.StateTransition == MarkovModel.State_Transition
>>> select StateTransition, initialState, (MarkovModel.countP+1) as
>>> updatedState_count
>>> insert into updateModel;
>>>
>>>
>>> ----------------------------------------------------------------------------------------------------------------------
>>>
>>> Want to know how get the total count of *Initial_state*'s from the
>>> above table as a continuation to the above query.
>>>
>>> Ex: HFS - 2
>>>       HTL - 2
>>>       HTM - 1
>>>       HTS - 4
>>>       MFM - 1
>>>       MTS - 1
>>>
>>> Would appreciate any suggestions.
>>>
>>> Thank you
>>> Regards
>>>
>>> *Supun Rasitha Muthutantrige*
>>> Software Engineer | Intern
>>> WSO2 Inc: http://wso2.com
>>> lean.enterprise.middleware
>>> Mobile: 0758374608
>>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Shashika Prabath Karunatilaka,
> Software Engineer,
> WSO2, Inc: http://wso2.com/
> mobile : +94 77 7487792
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to