Row to Col

0

Please login or register to vote for this query.

(click on this box to dismiss)

Robotics Meta

Q&A about the site for professional robotic engineers, hobbyists, researchers and students

CREATE table #table1
    (Campaign_ID varchar(50), SMS_TEXT_VAR_1 varchar(50),SMS_DATA_VAR_2 varchar(50))
;
    
INSERT INTO #table1
    (Campaign_ID,SMS_TEXT_VAR_1,SMS_DATA_VAR_2)
VALUES
('C0701002','Right now, you can...','handset_1_storage')
;

CREATE table #table2
    (Campaign_ID varchar(50), handset_1_storage varchar(50))
;
    
INSERT INTO #table2
    (Campaign_ID,handset_1_storage)
VALUES
('C0701002','64')
;
INSERT INTO #table2
    (Campaign_ID,handset_1_storage)
VALUES
('C0701003','65')
;


select a.Campaign_ID,SMS_TEXT_VAR_1 +
case SMS_DATA_VAR_2 WHEN 'handset_1_storage' then
(select handset_1_storage FROM #Table2 where Campaign_ID = a.Campaign_ID AND a.SMS_DATA_VAR_2='handset_1_storage') end msg
FROM #table1 a

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results