[storm] Query using count

akira nhytro-python at web.de
Tue Jul 24 12:31:55 BST 2007


Could someone help out? I still have´nt found a solution. I posted the 
whole query that I would like to replicate, maybe it got mixed up on the 
forum. Well here it is again:

SELECT Link,
         COUNT(*)-1 AS level
    FROM tree AS node,
         tree AS parent
   WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.lft
ORDER BY node.lft;

I have created aliases like this:

parent = ClassAlias(Link)
node = ClassAlias(Link)

this is how far I got

rows = store.find((node, parent), node.lft > parent.lft, node.lft < parent.rgt)



Thanks!


Jamu Kakar wrote:
> Hi Akira,
>
> akira wrote:
>   
>> this has brought me since yesterday to a grinding halt, I have run out
>> of ideas. Could someone tell me how to code this using Storm?
>>
>> SELECT n.name,  COUNT(*)-1 AS level
>>
>> I just dont know how to use Storms cout in such a query.
>>     
>
> I'm not sure I actually understand what you expect out of that query.
> Perhaps the following will help anyway: a query can yield a count by
> using the count() method on a ResultSet.  For example, consider
> counting Person instances.  You can do this to count all Persons whose
> name starts with Bob:
>
> count = store.find(Person, Person.name.like("Bob%")).count()
>
> Or this to count all Persons:
>
> count = store.find(Person).count()
>
> Does that help?
>
> Thanks,
> J.
>
>   




More information about the storm mailing list