dbTalk Databases Forums  

where cluase help please

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss where cluase help please in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Totti
 
Posts: n/a

Default where cluase help please - 01-15-2008 , 08:27 AM







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

Reply With Quote
  #2  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: where cluase help please - 01-15-2008 , 09:14 AM






On Jan 15, 8:27*am, Totti <saliba.toufic.geo... (AT) gmail (DOT) com> wrote:
Quote:
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


Reply With Quote
  #3  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: where cluase help please - 01-15-2008 , 09:14 AM



On Jan 15, 8:27*am, Totti <saliba.toufic.geo... (AT) gmail (DOT) com> wrote:
Quote:
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


Reply With Quote
  #4  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: where cluase help please - 01-15-2008 , 09:14 AM



On Jan 15, 8:27*am, Totti <saliba.toufic.geo... (AT) gmail (DOT) com> wrote:
Quote:
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


Reply With Quote
  #5  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: where cluase help please - 01-15-2008 , 09:14 AM



On Jan 15, 8:27*am, Totti <saliba.toufic.geo... (AT) gmail (DOT) com> wrote:
Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.