Re: SQL Query Question.

From: Karen Hill <karen_hill22_at_yahoo.com>
Date: 23 Dec 2005 16:34:41 -0800
Message-ID: <1135384481.717274.156730_at_z14g2000cwz.googlegroups.com>


X-No-Archive:yes
Hugo Kornelis wrote:
\
>
> This should work. As far as I know, it uses only ANSI-standard SQL
> constructs, so it should run on any ANSI-compliant database.
>
> SELECT salesman AS Salesperson,
> SUM(CASE WHEN sold <> 0 THEN amount ELSE 0 END) AS Totaled,
> COUNT(CASE WHEN lost <> 0 THEN 'Countme' END) AS "Number of
> Lost",
> COUNT(CASE WHEN sold <> 0 THEN 'Countme' END) AS "Number of
> Sales"
> FROM leads
> GROUP BY salesman
>
> I removed the inner join to the salesman table, since you don;t appear
> to use any of the columns in that table.
>

Hi Hugo,

Thanks for the response!

The salesman table is there so a salesman shows up if they didn't have any activity what so ever on the leads query. I will take the lessons you have given me and rework it.

Thanks for your help. Received on Sat Dec 24 2005 - 01:34:41 CET

Original text of this message