| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Many aggregates in one query
Matti Teppo wrote:
>
> > If you're using mySQL you can use the LIMIT clause which is specific to this
> > DBMS and do the following :
> > SELECT wsid, count(wsid) AS rowcnt
> > FROM test
> > GROUP BY wsid
> > ORDER BY rowcnt ASC
> > LIMIT 1;
> >
> > You just get the first result.
>
> Thank you, but I use Sybase so LIST is not available.
If you're using ASA 7 (and perhaps also 6), you can use the following query:
SELECT MIN(wsid), MIN(rowcnt)
FROM (SELECT wsid, COUNT(wsid) AS rowcnt
FROM test
GROUP BY wsid
HAVING COUNT(wsid) = MIN(COUNT(wsid)) t;
Perhaps it works for other DMBSs, too.
hth,
Heinz
Received on Fri Aug 17 2001 - 07:14:33 CDT
![]() |
![]() |