Home » SQL & PL/SQL » SQL & PL/SQL » Help needed in populating a column with the column value of another row (oracel 10g)
Help needed in populating a column with the column value of another row [message #427535] Fri, 23 October 2009 03:08 Go to next message
purohg
Messages: 10
Registered: June 2005
Location: Kolkata
Junior Member
Hi,
I need write a query for the following requirement.

Say, table A has 3 column c1,c2, c3 and c4.
this has data as
c 1 2 0
d 1 2 5.5
e 2 3 0
f 2 3 0
g 2 3 7.5

in the output i need as :

c 1 2 5.5
d 1 2 5.5
e 2 3 7.5
f 2 3 7.5
g 2 3 7.5

i.e populating the column c4 with a value not equal to 0 for the same value of column c2 and c3, for different value of column c1.

Please can anyone advice me on this..i am very new to this developer world.

Thanks a lot in advance.



Re: Help needed in populating a column with the column value of another row [message #427538 is a reply to message #427535] Fri, 23 October 2009 03:16 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
What should happen if there are multiple non 0 values for the same value of column c2 and c3, for different value of column c1?
Which value would you use?
Re: Help needed in populating a column with the column value of another row [message #427544 is a reply to message #427538] Fri, 23 October 2009 03:47 Go to previous messageGo to next message
purohg
Messages: 10
Registered: June 2005
Location: Kolkata
Junior Member
Thanks for your quick reply.
always it should pick up the maximum value.
Re: Help needed in populating a column with the column value of another row [message #427547 is a reply to message #427535] Fri, 23 October 2009 03:53 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
Do you just want a select that shows that output or do you want to actually update the data?
Re: Help needed in populating a column with the column value of another row [message #427554 is a reply to message #427535] Fri, 23 October 2009 04:29 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From your previous topic:

Michel Cadot wrote on Tue, 14 July 2009 18:52
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel


Post a working Test case: create table and insert statements along with the result you want with these data.

Previous Topic: Concatenate row values
Next Topic: Inserting record in Parent & child table
Goto Forum:
  


Current Time: Sun Dec 11 02:18:31 CST 2016

Total time taken to generate the page: 0.08114 seconds