MATRIX REPORT [message #525356] |
Sat, 01 October 2011 10:06 |
|
naeemrazaacma
Messages: 6 Registered: January 2011 Location: multan
|
Junior Member |
|
|
HI BOSS!
BOSS ! I MAKE A MATRIX REPORT (SALES) ALL CUSTOMER ALL PRODUCTS SUCCESSFULLY BUT NOW I WANT TO ADD A COLUMN NET BALANCE OF CUSTOMER. BUT I AM FAIL TO GET NET BALANCE FROM ACCOUNTS TABLE.
MY TABLES WHERE I GET INFORMATION THESE
SALEM----SALE MASTER=== INVNO,INVDATE,ACODE REFERNCES BY ACC(TABLE)
SALED----SALE DETAIL=== ITEMCODE REFERNCES BY ITEM(TABLE),QTY,AMOUNT
ITEM-----ITEM======ITEMCODE,ITEMNAME
ACC------ACCOUNT REGISTRATION ---------ACODE,AHEAD
ACCDET---ACCOUNT DETAIL-----------ACODE,DR,CR
ACCMAS---ACCOUNT MASTER-------INVNO,INVDATE
THESE ARE MY TABLES AND FIELDS OF TABLES.
MATRIX SALES REPORT THIS QUARY I USE FOR MATRIX I GET ACCURATE SALES REPORT WHEN I ADD ACCOUNT INFORMATION THEN ITS SHOW BALANCE BUT WRONG AND SAME BALANCE FOR ALL CUSTOMER.
SELECT ALL SALED.ITEMCODE,
ITEM.ITEMNAME,
SALED.QTY,
SALED.AMOUNT,
SALEM.ACODE,
ACC.AHEAD
FROM ACC,ITEM,SALED,SALEM
WHERE SALEM.INVNO=SALED.INVNO
AND SALEM.ACODE=ACC.ACODE
AND ITEM.ITEMCODE=SALED.ITEMCODE;
I USE COLUMN FORMULA
function CF_1Formula return Number is
DRS NUMBER;
begin
SELECT SUM(DR) INTO DRS FROM ACCDET
WHERE ACCDET.ACODE=ACODE;
RETURN DRS;
end;
BUT RESULT IS WRONG---PLZ HELP ME.
|
|
|
|
Re: MATRIX REPORT [message #525403 is a reply to message #525380] |
Sun, 02 October 2011 09:29 |
ranamirfan
Messages: 535 Registered: January 2006 Location: Pakistan / Saudi Arabia
|
Senior Member |
|
|
Dear,
Create a Function and used it in a main query.
Create or Replace Function Get_Acct_Sum(AccCode in Number) Return Number is
Drs Number;
Begin
Select Sum(Nvl(DR,0)) Into Drs
From AccDet
Where AccDet.ACode=AccCode;
Return Drs;
End;
Then Use this function here.
SELECT Saled.ItemCode,
Item.ItemName,
Get_Acct_Sum (Acc.ACode)Acct_Amount,
Saled.Qty,
Saled.Amount,
Saled.Acode,
Acc.Ahead
FROM Acc,
Item,
Saled,
Salem
WHERE Salem.InvNo=Saled.Invno
AND Salem.Acode=Acc.Acode
AND Item.ItemCode=Saled.ItemCode;
Try it.
Regards,
Irfan
|
|
|
|
|
|
|
|
|
|
Re: MATRIX REPORT [message #525555 is a reply to message #525491] |
Mon, 03 October 2011 13:41 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Besides, it appears that you are trying to return NULL. Are you sure you want to do that? I suppose you should return DRS instead.
|
|
|