Thank you Vasily,
however I am using ODMG, and I am not sure on how to integrate your
suggestion within ODMG.

Actually the sequence of instruction I use is the following:
    Implementation odmg = OJB.getInstance();
    Transaction tx = odmg.newTransaction();
    tx.begin();
    OQLQuery query = odmg.newOQLQuery();
    String oqlQuery = "select ... from " + (Class)MyClass).getName();
    query.create(oqlQuery);
    Object queryResult = query.execute();
    Iterator itr = ((ManageableCollection)queryResult).ojbIterator();

Thank you,
Francesco.


> 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]
>>
>>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to