Re: How-To select on a "group" function
"Vasily Ivanov" <[email protected]>
| Newsgroups | gmane.comp.jakarta.ojb.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Francesco,
You can do the following:
ReportQueryByCriteria query = QueryFactory.newReportQuery(Clazz.class,
new Criteria());
query.setAttributes(new String[] { "max(value1)", "value2" });
query.addOrderByAscending("max(value1)");
query.addGroupBy("value2");
Iterator itr = pb.getReportQueryIteratorByQuery(query);
I hope that helps.
Regards,
Vasily
On 11/22/06, Francesco Martinelli <[email protected]> wrote:
> Hi,
>
> I would like to retrieve a record using the following SQL-Like statement:
> "select max(value) from " + className
>
> Does anyone know how to "convert" this to OQL?
>
> I know it would be possible to retrieve all the records, then sort them
> out, and pick up the first, but I would prefer to reduce the amount of
> data retrieved from the database.
>
> I also wonder if it were possible to order the "resultset" according to
> one field, e.g. of SQL-like would be:
> "select xxx from " + className + " order by value".
>
> Thenk you,
> Francesco.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>