December 10th, 2003, 04:14 PM
Query one column to populate another
I wonder if you can offer some assistance with this query.
I need to query a table in SQL2000 to read the value in one column and populate a new column with new data. For example:
If Column A = ABC in table Class_001 I need a query statement to populate Column Z with 123
If Column A = XYZ in table Class_001 I need a query statement to populate Column Z with 789
Your help would be much appreciated.
December 10th, 2003, 04:38 PM
set Z = case when A = 'ABC'
else 789 end
where A in ('ABC','XYZ')
December 10th, 2003, 05:58 PM
Many thanks for your quick reply.
Your query works but I have changed it slightly as I would like to populate Test with different data depending on the data in PN
This is my effort..... Is there an easier way?
set Test = '1' where PN = '3001'
set Test = '2' where PN = '3002'
set Test = '3' where PN = '3003'
December 10th, 2003, 07:20 PM