How will we handle a complex query in CMP?
I am using wsad 5.0 and how can we handle a complex query such as a self join and join condition with multiple tables and involving aggregate functions and relations of cardinality many-to-many. I have some example QJB QL
e.g.:

1. This is a simple

select object(c4) from CMP4 c4 where c4.id = ?1

Relation
2. Joining two tables
Cmp4 to cmp3 a one-to-many or a many-to-many relation

select object(l) from CMP4 o, in(o.cmp3) l where l.street = ?1

We can set further more conditions with l but can we have aggregate functions lilke avg() with l in the previous query?

3. Joining three tables
Cmp4 to cmp3 is a one-to-many or a many-to-many relation
Cmp3 to cmp5 is a one-to-many or a many-to-many relation


select object (l) from CMP4 o, in (o.cmp3) l, in (o.cmp3.cmp5) m where l.some=" " and o.cmp5.next="";

We can set further more conditions with l but can we have aggregate functions lilke avg() with m in the previous query?

Can any body comment on these queries?