Hello,
Seems I'm back to this problem (XWiki 3.5), and I did not find a
solution still ...
For example this XWQL request :
select topic.author, count(topic.author)
from Document doc, doc.object(MailArchiveCode.MailTopicClass) as topic
where doc.space<>'MailArchiveCode'
group by topic.author
order by count(topic.author) desc
... will throw this exception when executed :
Caused by: org.xwiki.query.jpql.parser.ParserException: [1,165] expecting: id
at org.xwiki.query.jpql.parser.Parser.parse(Parser.java:1247)
at org.xwiki.query.jpql.internal.JPQLParser.parse(JPQLParser.java:46)
at
org.xwiki.query.xwql.internal.hql.XWQLtoHQLTranslator.translate(XWQLtoHQLTranslator.java:55)
at
org.xwiki.query.xwql.internal.XWQLQueryExecutor.execute(XWQLQueryExecutor.java:78)
... 123 more
Column 165 refers to the count in the order by clause.
This does not work better :
select topic.author, count(topic.author)
from Document doc, doc.object(MailArchiveCode.MailTopicClass) as topic
where doc.space<>'MailArchiveCode'
group by topic.author
order by 2 desc
It does not work with a MySQL nor HSQLDB default db.
If I remove the order by clause, the query works correctly.
I think it's strange because for me ORDER BY COUNT(<column>) is valid
in JPQL ? As long as the expression is also present in the SELECT
clause.
Thanks,
Jeremie
2011/10/18 jerem <[email protected]>
>
> Hi,
>
> I'm trying to use XWQL query language to select count of authors and would
> like to order this by descending order of this count.
>
> I ended up having this work fine :
>
> "select count(myobject.author), myobject.author from Document as doc,
> doc.object(Space.MyClass) as myobject group by myobject.author"
>
> But adding " order by count(myobject.author) desc" leads to an error for
> translating the query ...
> Adding "AS" in the select expression does not seem to work either.
>
> Is this possible in XWQL and how ?
>
> Thanks,
> Jeremie
>
> --
> View this message in context:
> http://xwiki.475771.n2.nabble.com/XWQL-order-by-count-tp6904819p6904819.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users