Home » SQL & PL/SQL » SQL & PL/SQL » Decode help
Decode help [message #189847] Mon, 28 August 2006 01:45 Go to next message
sanjit
Messages: 65
Registered: November 2001
Member
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
rleishman
Messages: 3724
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: Question about cursors (merged)
Next Topic: Help Me
Goto Forum:
  


Current Time: Sat Dec 10 15:07:54 CST 2016

Total time taken to generate the page: 0.08067 seconds