Oracle Query

Greetings,

I have 3 fields with sampel data in oracle below.
I need to a query to get the total amount(group by ID). If type='D' the positive number, If Type='C' then it should be a negative number.



ID Type   Amount
1     D       200
2     C       100

Thanks in advance.
mrongAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
awking00Connect With a Mentor Commented:
select id, type, decode(Type,'D',Amount,'C',-1 * Amount) Amount
0
 
sdstuberConnect With a Mentor Commented:
select id, sum(case when type  ='D' then amount else  -amount end) from yourtable
group by id
0
All Courses

From novice to tech pro — start learning today.