[storm] Query using count
nhytro-python at web.de
nhytro-python at web.de
Sat Jul 21 13:30:25 BST 2007
Thanks for the reply Jamu, this is actually the whole query IŽm trying to replicate using Sorm ORM:
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)
I just dont know how to use count in the query.
Thanks so much
> -----Ursprüngliche Nachricht-----
> Von: Jamu Kakar <jamshed.kakar at canonical.com>
> Gesendet: 21.07.07 00:39:32
> An: akira <nhytro-python at web.de>
> CC: storm at lists.canonical.com
> Betreff: Re: [storm] Query using count
> 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.
>
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
More information about the storm
mailing list