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: Challenging SQL Query Problem. Can you solve it?

Re: Challenging SQL Query Problem. Can you solve it?

From: T3 <c.maradey2_at_verizon.net>
Date: 22 Dec 2005 13:30:16 -0800
Message-ID: <1135287016.150898.127770@z14g2000cwz.googlegroups.com>


Hi Karen,

After looking at both your queries I think it's best if you just combine them into one that sums both sold and lost for each salesperson. I think this will work for you.

  SELECT leads.salesman AS Salesperson,

         COUNT(DECODE(LOST,-1,1,0)) AS [Number of Lost],
         COUNT(DECODE(SOLD,-1,1,0)) AS [Number of Sales]
    FROM leads , salesman
   WHERE leads.salesman = salesman.salesman GROUP BY leads.salesman;

I do not have the tables to run but am pretty sure it will work for you.

T3 Received on Thu Dec 22 2005 - 15:30:16 CST

Original text of this message

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