Re: A Table Manipulation question. I'm stuck
Posted by: Paul Zorsky
Date: October 15, 2015 05:23PM

Thank you

UPDATE table2 t2 LEFT JOIN table1 t1 on t1.table1ID = t2.table1ID and t1.table1ID IN (1,5)
SET t2.parameter1 = t1.parametervalue;

I have 2 tables. Table1 has an ID,'table1ID', a date field, an item field, and an itemValue field. I need to transpose the data such that the second table has one row for all the items in table1 for a given date.

table 1
ID DATE ITEM ITEMVALUE
1 d1 item1 1
2 d1 item2 2
3 d1 item3 1
4 d2 item1 4
5 d2 item2 5

table2
Table2ID DATE item1 item2 item3
1 d1 1 2 1
2 d2 4 5

I think the above query needs to define a variable @var that can be used for
t1.parameter1
t2.parameter2
etc such that SET @var = t1.parameterValue

One option is to use one update statement for each table2 column but using a variable referring to the column identifier, not the value, seems useful

Thanks

Options: ReplyQuote


Subject
Written By
Posted
Re: A Table Manipulation question. I'm stuck
October 15, 2015 05:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.