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