On Oct 27, 11:31 am, sunidhi ahuja <[email protected]> wrote:
> Hello Trail,
>
> Thanks for your suggestion. But wat I need is insertion of data as shown in
> output to Table : A. not selection.
>
> I need PL/SQL query not sql statements.
>
> thanx
>
>
>
> On Tue, Oct 27, 2009 at 8:01 PM, Trail <[email protected]> wrote:
>
> > 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

It does look rather like an exam question doesn't it.

It also does NOT require PL/SQL a simple Insert statement will do
unless you need extensive error handling, which you haven't mentioned.

I suggest reading 
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2064341
and all will be revealed. The first place you look should always be
the documentation or even a google search as follows
http://www.google.com/search?q=insert+oracle+subquery

Sorry to sound condescending here but this is too elementary a problem
to be coming from someone that is other than a student and while we
will give hints and help on some of the more strange bits of PL/SQL we
do not in general do people's homework for them.

Rob


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to