Home » SQL & PL/SQL » SQL & PL/SQL » Decode help
Decode help [message #189847] Mon, 28 August 2006 01:45 Go to next message
Messages: 65
Registered: November 2001
I have records in the table xyz
col1   col2   col3
A	-12   45
B       -65   10
A       70    -53

I am grouping a record based out of col1 and sum(col2) & sum(col3)

and based out of the result I want to create another 2 rows in the table so that value of sum(col3) goes absolutly equal to sum(col2)
so that at any stage the value at group by at col1 should always be zero.

similar to
col1   col2   col3
A	-12   45
B       -65   10
A       70    -53
A       -58   8
B       65    -10

now i am trying to creata a similar line by procedure,(line 4& 5) , is there any way to use Decode value to repalce the value agasist the column.
Re: Decode help [message #189907 is a reply to message #189847] Mon, 28 August 2006 07:46 Go to previous message
Messages: 3727
Registered: October 2005
Location: Melbourne, Australia
Senior Member
I'm afraid I'm not much help; I can't think of a rational way to do it with DECODE().
insert into xyz
select col1, -sum(col2), -sum(col3)
from xyz
group by col1
having sum(col2) <> 0
or sum(col3) <> 0

Ross Leishman
Previous Topic: executing a package.procedure
Next Topic: ORA-06532: Subscript outside of limit
Goto Forum:

Current Time: Sun Aug 20 06:47:32 CDT 2017

Total time taken to generate the page: 0.22593 seconds