Home » SQL & PL/SQL » SQL & PL/SQL » Values to columns of another table (Oracle 11g R2)
Values to columns of another table [message #573058] Thu, 20 December 2012 07:00 Go to next message
srinivas.k2005
Messages: 299
Registered: August 2006
Senior Member
Hi,

I need to add values of one column values from a table to another table each value as a column.

Below i am considering only for 3 values in real time i have more than 50 values
CREATE TABLE TEST_REG ( VAL VARCHAR2(1));

INSERT INTO TEST_REG VALUES ('A');
INSERT INTO TEST_REG VALUES ('B');
INSERT INTO TEST_REG VALUES ('C');

CREATE TABLE TEST_HOLD ( COL1 VARCHAR2(1),COL2 VARCHAR2(1),COL3 VARCHAR2(1)); -- in realtime i have 100 columns



Now i need the output as:

when i
select * from test_hold;

COL1 COL2 COL3
A B C


Thanks,
SRK
Re: Values to columns of another table [message #573062 is a reply to message #573058] Thu, 20 December 2012 07:13 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What do you want to do? A+B?

Your test case is really STUPID.

Regards
Michel
Re: Values to columns of another table [message #573077 is a reply to message #573062] Thu, 20 December 2012 10:09 Go to previous messageGo to next message
srinivas.k2005
Messages: 299
Registered: August 2006
Senior Member
Its not Stupid case, may be you were unable to understand.

I have a master table with master region values..in above example A,B and C

Now i have another table where i need to insert each value in different column and show number of records belonging to that region..i made the same case simpler with above example.

Re: Values to columns of another table [message #573078 is a reply to message #573077] Thu, 20 December 2012 10:21 Go to previous messageGo to next message
BlackSwan
Messages: 22793
Registered: January 2009
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: Values to columns of another table [message #573090 is a reply to message #573077] Thu, 20 December 2012 12:43 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Its not Stupid case, may be you were unable to understand.


It is stupid and may be you are unable to express it because you do not understand it.

With any SQL or PL/SQL question, please, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Regards
Michel
Re: Values to columns of another table [message #573107 is a reply to message #573090] Thu, 20 December 2012 20:03 Go to previous messageGo to next message
Flyby
Messages: 144
Registered: March 2011
Location: Belgium
Senior Member
A pivot operation?
Re: Values to columns of another table [message #573121 is a reply to message #573107] Fri, 21 December 2012 02:21 Go to previous message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Maybe but we have no information about what OP actually wants to do.

Regards
Michel
Previous Topic: Compare last price of the day and present price
Next Topic: Group by matching records
Goto Forum:
  


Current Time: Sun Sep 21 11:37:36 CDT 2014

Total time taken to generate the page: 0.08854 seconds