Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql query help

Re: sql query help

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Tue, 04 Mar 2003 16:08:23 -0800
Message-ID: <3E653FF7.A9903428@exesolutions.com>


steve wrote:

> hi peeps
>
> i have a table set up
>
> table: orderitems
> orderid
> productid
> qty
>
> is there anyway of listing productid of items ordered x times?
>
> i have managed to get basic things working but found no reference to this
> and not sure if the set up of my database would allow such a query
>
> cheers :)
>
> --
> get me tools and beer

There is indeed.

SELECT productid, COUNT(*)
FROM orderitems
GROUP BY productid
HAVING COUNT(*) = x;

Go to http://tahiti.oracle.com and search on GROUP BY.

Daniel Morgan Received on Tue Mar 04 2003 - 18:08:23 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US