How do I Add a value of records concidentes records

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
  

Poston Tue, 09 May 2006 10:39 am

Dear friends I am with a debt and I can't resolvela, I beg help to the srs.

Have a parent table, which contains COD_PROD, SEQ_PROD, VALOR_PROD. (COD, can repeat the SEQ cannot)
I have another child table that contains the creditors of these products: COD_PROD, SEQ_PROD, CREDOR_PRODUT. (I may have no creditors for each product, lenders can be uguais for each product or different.)
My problem is: I have to show in a report the values of each product with the following conditions: If the products don't have creditors and have the same code, sum up their value in case the products have exactly the same lenders and the same code, there are no House and tbém ocora, show the distinct value of each product.

Please help: roll:
vindalencio
Location: Curitiba

Vanderlei Indalencio

Poston Tue, 09 May 2006 11:56 pm

Dude use the technique \"divide and conquer\".
For example, resolves this first:
if the products don't have creditors and have the same code, sum up their value SELECT p. COD_PROD, sum (p. VALOR_PROD) FROM PRODUCTS P WHERE NOT EXISTS (SELECT 1 FROM PRODUTO_CREDORES C WHERE COD_PROD = p. c. COD_PROD AND c. SEQ_PROD = p. SEQ_PROD) GROUP BY p. COD_PROD
After this:
If the products have exactly the same lenders and the same code, added tambémém
and finally:
and it doesn't show the ocora distinct value for each product.


Resolving these parts you can use resources that a database has managed: views, procedures and functions, to put the pieces together.

Gilberto
gilbertoca
Location: Palmas - TO


Poston Thu, 11 May 2006 10:01 am

Thank You, Gilberto ....

I'll try ...:-
vindalencio
Location: Curitiba

Vanderlei Indalencio



Return to PL/SQL

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 6 guests