Re: where cluase help please

From: <fitzjarrell_at_cox.net>
Date: Tue, 15 Jan 2008 07:14:13 -0800 (PST)
Message-ID: <63689982-b75f-4653-92b1-0f6d419e2259@i12g2000prf.googlegroups.com>


On Jan 15, 8:27 am, Totti <saliba.toufic.geo..._at_gmail.com> wrote:
> hi all. i want to Produce  total sales per month per indicated
> region.
>
> The total should include only sales of products with more than
> 4,000,000 total sales.
> i did the following but it is giving me huge number:
> somebody please tell me why?
>
> SELECT TO_CHAR(purinv.Inv_Date,'mm') || ' - ' ||
> TO_CHAR(purinv.Inv_Date,'yy') as "MONTH",
> sum(decode(cust.region, 'West', sales.qty*salpmt.amount, 0)) as
> "West",
> sum(decode(cust.region, 'North', sales.qty*salpmt.amount, 0)) as
> "North"
> from  prod, cust, salpmt, sales, purinv
> where salpmt.cust_code = cust.code
> and cust.region in ('North','West')
> and (sales.qty*salpmt.amount) > 4000000
> group by TO_CHAR(purinv.Inv_Date,'mm'),
> TO_CHAR(purinv.Inv_Date,'yy')
> order by TO_CHAR(purinv.Inv_Date,'yy')
>
> thanks in advance

Why is there no mention, in your query, of item numbers or product ids? What is the criteria for matching the sales.qty to the salpmt.amount?

David Fitzjarrell Received on Tue Jan 15 2008 - 09:14:13 CST

Original text of this message