Re: Count a Subquery with group clause
"Vasily Ivanov" <[email protected]>
| Newsgroups | gmane.comp.jakarta.ojb.user |
|---|---|
| Message-ID | <[email protected]> |
Sorry,
Read this:
subQuery.addGroupBy(new String[] { "lastname, age, city" });
as this:
query.addGroupBy(new String[] { "lastname, age, city" });
Cheers,
Vasily
On 8/9/06, Vasily Ivanov <[email protected]> wrote:
> Hi Bin,
>
> Your query will not run because you can not put in GROUP BY without
> count(*) in SELECT clause of subquery. If you want to run this:
> =================
> SELECT lastname, age, city, count(*)
> FROM people
> GROUP BY lastname, age, city
> =================
> that you shoud do something like this in OJB:
> =================
> ReportQueryByCriteria query =
> QueryFactory.newReportQuery(People.class, new Criteria());
> query.setAttributes(new String[] { "lastname, age, city, count(*)" });
> subQuery.addGroupBy(new String[] { "lastname, age, city" });
> broker.getReportQueryIteratorByQuery(query);
> =================
>
> Cheers,
> Vasily
>
> On 8/9/06, Bin Gao <[email protected]> wrote:
> > Hello All,
> >
> > How can I generate the following SQL statement using
> > OJB?
> >
> > SELECT count(*) FROM (
> > SELECT lastname, age, city
> > FROM people
> > GROUP BY lastname, age, city
> > );
> >
> > Thanks for your help,
> >
> > Bin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>