<br> Not really... all solutions are variations of this. :(<br><br> We do intent to develop things equivalent to SQL group by, unique, etc clauses... but no such feature today.<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2008/1/29, cfili <<a href="mailto:cfilippelli@cerner.com">cfilippelli@cerner.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Yeah I tried your first suggestion and ran into the duplication. I'd rather<br>not create a new fact for each one of these... any other way of avoiding it?<br><br><br>Edson Tirelli-3 wrote:<br>><br>> Sorry, my previous suggestion will count the same process name multiple<br>
> times. There are a few ways to avoid it. I would probably use a helper<br>> fact:<br>><br>> rule XYZ<br>> when<br>> $p : Process( $name : name )<br>> not( ProcessCount( name == $name ) )<br>
> Number( $count : intValue) from accumulate(<br>> $i : Process( name == $name, this != $p ),<br>> count( $i ) )<br>> then<br>> System.out.println( "There are "+$count+" instances of processes<br>
> named "+$name );<br>> insert( new ProcessCount( $name, $count ) );<br>> end<br>><br>><br>> Hope it helps,<br>> Edson<br>><br>> 2008/1/29, Edson Tirelli <<a href="mailto:tirelli@post.com">tirelli@post.com</a>>:<br>
>><br>>><br>>> Try that:<br>>><br>>> rule XYZ<br>>> when<br>>> $p : Process( $name : name )<br>>> Number( $count : intValue) from accumulate(<br>>> $i : Process( name == $name, this != $p ),<br>
>> count( $i ) )<br>>> then<br>>> System.out.println( "There are "+$count+" instances of processes named<br>>> "+$name );<br>>> end<br>>><br>>> []s<br>
>> Edson<br>>><br>>><br>>> 2008/1/29, cfili <<a href="mailto:cfilippelli@cerner.com">cfilippelli@cerner.com</a>>:<br>>> ><br>>> ><br>>> > I am having a hard time finding an example of what I am trying to do,<br>
>> so<br>>> > maybe someone here could help me. What I am trying to do is determine<br>>> > how<br>>> > many facts fall into the same category.<br>>> ><br>>> > My facts are 'processes' and one of their attributes is a 'name'. My<br>
>> > goal<br>>> > is to determine how many processes with the same name are running. The<br>>> > problem is I do not know ahead of time the process names available, I<br>>> > want<br>>> > to determine that set at runtime. Also, once I determine the count for<br>
>> > a<br>>> > given name, I do not want to run it again for the other processes that<br>>> > fall<br>>> > in that name category.<br>>> ><br>>> > I think "from collect" is probably what I want to use here, but I am<br>
>> not<br>>> > sure how to grab the names in my Pattern from the fact I am currently<br>>> > iterating on.<br>>> ><br>>> > Thanks.<br>>> > --<br>>> > View this message in context:<br>
>> > <a href="http://www.nabble.com/Count-matching-facts-tp15160392p15160392.html">http://www.nabble.com/Count-matching-facts-tp15160392p15160392.html</a><br>>> > Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>
>> ><br>>> > _______________________________________________<br>>> > rules-users mailing list<br>>> > <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>>> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>> ><br>>><br>>><br>>><br>>> --<br>>> Edson Tirelli<br>>> JBoss Drools Core Development<br>>> Office: +55 11 3529-6000<br>>> Mobile: +55 11 9287-5646<br>>> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
><br>><br>><br>><br>> --<br>> Edson Tirelli<br>> JBoss Drools Core Development<br>> Office: +55 11 3529-6000<br>> Mobile: +55 11 9287-5646<br>> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
><br>> _______________________________________________<br>> rules-users mailing list<br>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>><br><br>--<br>View this message in context: <a href="http://www.nabble.com/Count-matching-facts-tp15160392p15163614.html">http://www.nabble.com/Count-matching-facts-tp15160392p15163614.html</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>
<br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>