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: DA Morgan <damorgan_at_psoug.org>
Date: Thu, 22 Dec 2005 14:39:08 -0800
Message-ID: <1135291132.681369@jetspin.drizzle.com>


Karen Hill wrote:
> X-No-Archive:yes
>
> T3 wrote:
>

>>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.
>>

>
>
>
> Thank you for your response. Is there any way to do it without the
> DECODE? My DBMS doesn't have DECODE unfortunately.
>
> Thanks,
>
> karen

There is no such thing as an Oracle database without it.

Why are you posting in c.d.o.misc if you are not using Oracle?

-- 
Daniel A. Morgan
http://www.psoug.org
damorgan_at_x.washington.edu
(replace x with u to respond)
Received on Thu Dec 22 2005 - 16:39:08 CST

Original text of this message

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