Interesting problem - looks like an exam question. PL/SQL isn't really required here - simply use SQL to DECODE (or CASE) the original sub-codes into either 2501 or 2502 (if those are not columns in the table already) and SUM the amount.
Lookup "DECODE" or "CASE", as well as doing SUMs and you should have your answer. You will need to include the DECODE or CASE statement in your GROUP BY clause (for your SUM) -A. On Oct 27, 10:20 am, sunidhi ahuja <[email protected]> wrote: > Hi all, > > Need to get desired output as mentioned below > Let me explain :- > > I got table A in which material from different vendors with sub-code is > coming but I want to post their total amount to their sub code category in > which they are coming like given in as given below. > > Pls help me to resolve this issue t earliest. > > Like table as showed > > Table: - A (I got this) > > CCode Sub-Code Type Vrno Sr Debit Amount > > 1810 2701 Purchase 1 1 1 100 > > 1810 2703 Purchase 1 2 1 300 > > 1810 2704 Purchase 1 3 1 500 > > 1810 2707 Purchase 1 4 1 200 > ----------------------------------------------------------- > 1810 2702 Purchase 1 5 1 400 > > 1810 2706 Purchase 1 6 1 200 > > 1810 2709 Purchase 1 7 1 300 > > 1810 2708 Purchase 1 8 1 900 > > Ccode same 1810 > Sub-Code (2701, 2703, 2704, and 2707) comes under 2501 sub code whose total > is 1100 > Sub-code (2702, 2706, 2709, and 2708) comes under 2502 sub code whose total > is 1800 > > Table: - A Desired Output > > Total amount of sub-codes to be posted under their sub-code category > > CCode Sub-Code Type Vrno Credit Amount > > 1810 2501 Bank 1 2 1100 > > 1810 2502 Bank 1 2 1800 > . > . > . > . > > I need to do it as early as possible. (PL/SQL block) > > rgds, > > Sunidhi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Oracle-PLSQL?hl=en -~----------~----~----~----~------~----~------~--~---
