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: newbie sql question

Re: newbie sql question

From: Karsten Farell <kfarrell_at_medimpact.com>
Date: Wed, 02 Oct 2002 22:19:39 GMT
Message-ID: <%hKm9.1531$x_2.152754369@newssvr13.news.prodigy.com>


ksmith wrote:
> Orace 8i on Linux RH7.2
> I have two tables, a workorders table and a quotes table. I am trying to
> count all of the parts that are in the workorders table AND in the quotes
> table year to date. However they need to be distinct.

Something (exactly) like this:

select q.customerid, q.partid, count(*)
from quotes q, workorders wo
where q.partid = wo.partid
and q.customerid = wo.customerid
and to_number(to_char(q.datetimequoted,'yyyy')) =

          to_number(to_char(sysdate,'yyyy')) and wo.datetimeentered > q.datetimequoted group by q.customerid, q.partid
order by q.customerid, q.partid;

> However, I want a count and not the actual customer and part id.
> wishful SQL:
> select count(distinct q.partid, q.customerid)
> .....
>

For your wishful SQL, you could do this (but I doubt that's what you're really looking for):

select count(distinct q.partid || q.customerid)...

And for the record, this doesn't sound like a homework assignment to me.

-Karsten Received on Wed Oct 02 2002 - 17:19:39 CDT

Original text of this message

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