Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: newbie sql question
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
![]() |
![]() |