Re: simple create view sql help needed please.

From: Marc <langkamp_at_mailcity.com>
Date: Thu, 24 Jan 2002 10:43:13 +0100
Message-ID: <3c4fd72b$1_at_gaspra.oss.akzonobel.nl>


Create view view_name as select
account_number
, sum (decode(sign(gdet_amount) ,-1,gdet_amount,0) credit , sum (decode(sign(gdet_amount) , 1,gdet_amount,0) Debit From table
where (conditions)
group by account_number

sign() returns either -1,1,0 or null
decode (a,b,c

                ,e,f
                ,g)

  returns : if a =b then return c, elsif a = e then return f, else return g (in the view above I use decode(a,b,c,g )

Hth

Marc

<thajman_at_yahoo.com> wrote in message
news:3c4f4959.82942335_at_news-central.giganews.com...
> I am trying to create a summary view of some general ledger accounting
> data.
>
> Basically I would like the total debits (sum of gdet_amount >0) and
> credits (sum of gdet_amount <0) for each account (gdet_account)
>
> I am obviously an inexperienced SQL person and would appreciate one of
> you gurus helpimg me out! I have tried many different things and have
> come up empty.
>
> TIA!
>
> Jason
Received on Thu Jan 24 2002 - 10:43:13 CET

Original text of this message