I have a table with the structure below :
Table(customer_Num int , Channel_Id Varchar(50) , Branch_Code int)
and some example data for this table is :
Table
__________________________________________
customer_Num | Channel_Id | Branch_Code
1 | 'I' | 1000
1 | 'Y' | 1001
1 | 'L' | 1002
and the final result I want in the output is :
Result_table
__________________________________________________________
customer_Num | I_branch_Code | Y_branch_Code | L_Branch_Code
1 1000 1001 1002
is there a better solution rather than using continuous Insert
queries? Cause with this query
I will have many nulls in my final table!And I also won't have the result in one record.
insert into Result_table (customer_Num ,I_branch_Code )
select customer_Num , Branch_Code
from Table
where Channel_Id = 'I';
insert into Result_table (customer_Num ,Y_branch_Code )
select customer_Num , Branch_Code
from Table
where Channel_Id = 'Y';
insert into Result_table (customer_Num ,L_Branch_Code)
select customer_Num , Branch_Code
from Table
where Channel_Id = 'L';