dbTalk Databases Forums  

formula help please

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


Discuss formula help please in the comp.databases.oracle.misc forum.



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

Default formula help please - 01-05-2008 , 04:46 PM






hi all , i want to take out of the data (more than one table) the
total purchases and the total sales, put each in a column near to each
others and group the rows by months and years, so i thought in pseudo
code something like this would work:

if to_char of date (MM-YY).sales = to_char of date (MM-YY).purchase
and prod.code.sal = prod.cod.purch than qty*unit_price(x) in "tot
purch" and qty*unit_price(y)in "tot sales"
from tables
where prod_cod = prod_cod
so with this logic i did this:

select TO_CHAR(purinv_1.Inv_Date,'mm') || ' - ' ||
TO_CHAR(purinv_1.Inv_Date,'yy') as "MONTH",
sum(case when to_char(salpmt_1.pmt_date,'MM-yy') =
to_char(purpmt_1.pmt_date,'MM-yy') and to_char(salpmt_1.pmt_date,'mm-
YY') = to_char(purpmt_1.pmt_date,'mm-YY') then
(sales_1.QTY*prod_1.UNIT_PRICE)else 0 end) as "Total Sales",
sum(case when to_char(salpmt_1.pmt_date,'MM-yy') =
to_char(purpmt_1.pmt_date,'MM-yy')
and to_char(salpmt_1.pmt_date,'mm-YY') = to_char(purpmt_1.pmt_date,'mm-
YY') then (purch_1.QTY*purch_1.UNIT_PRICE)else 0 end) as "Total
Purchase"

from purinv_1, sales_1,purpmt_1,salpmt_1, prod_1,purch_1
where sales_1.prod_code = purch_1.prod_code
group by TO_CHAR(purinv_1.Inv_Date,'mm'),
TO_CHAR(purinv_1.Inv_Date,'yy')
order by TO_CHAR(purinv_1.Inv_Date,'yy')

eventhough i dont see anything wrong(**to my knowledge)
but i am having the following problem :
whenever i try to execute it the cpu goes 100% for about 5 -6 min and
than crashes what would the cause be ?

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.