Make Condition in Decode Function (Tip)

In this forum you can share stuff related to Oracle 11g, 10g, 9i.
Post Reply
mirza_rehan
Posts: 132
Joined: Sun Apr 02, 2006 10:36 am
Location: Pakistan

Make Condition in Decode Function (Tip)

Post by mirza_rehan »

Senerio: Table name GLTbl have 2 Column AmtDr and AmtCr
If Sum(AmtDr) > Sum(AmtCr) then
Sum(AmtDr) - Sum(AmtCr);
ElsIf Sum(AmtDr) < Sum(AmtCr)
Sum(AmtCr) - Sum(AmtDr);
Else
0;
End If;

Select Decode( Sign(Nvl(Sum(AmtDr),0) - Nvl(Sum(AmtCr),0)), 1, Nvl(Sum(AmtDr),0) - Nvl(Sum(AmtCr),0),-1, Nvl(Sum(AmtCr),0) - Nvl(Sum(AmtDr),0),0) Balnce
From GlTbl;

take care


Best regards,
R E H A N M I R Z A
System Analyst / Senior Oracle Developer
Cell: +92-304-2120807

When ever you pray
Please remember me and my family
najm
Posts: 74
Joined: Wed Apr 05, 2006 8:04 am
Location: Pakistan

Post by najm »

Asalam-u-alikum
Rehan bahi It's Najm how are you i am on 20 days Leave now i am back i want to know where we use this type of query or also mention the condition/concept of this query it's very typical



Chears
Najm

Najm
admin
Posts: 2063
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Post by admin »

Ya better to have some output as well on the basis of sample data.thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests