[storm] Query using count
Gustavo Niemeyer
gustavo at niemeyer.net
Mon Jul 30 17:36:06 BST 2007
akira wrote:
> 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 the equivalent expression:
columns = (parent.link, Count(*)-1)
where = And(node.lft >= parent.lft, node.lft <= parent.rgt)
expr = Select(columns, where, order_by=node.lft, group_by=node.lft)
> this is how far I got
>
> rows = store.find((node, parent), node.lft > parent.lft, node.lft < parent.rgt)
As we discussed in the other thread, the group_by feature in the store is
designed but not yet implemented.
--
Gustavo Niemeyer
http://niemeyer.net
More information about the storm
mailing list