SQL Convert Rows to Columns and Columns to Rows without using Pivot Functions

Опубликовано: 04 Октябрь 2024
на канале: Ankit Bansal
124,188
2.9k

In this video we will discuss how to convert rows to columns and vice versa without using pivot functions. Below is the script to create table and data:

create table emp_compensation (
emp_id int,
salary_component_type varchar(20),
val int
);
insert into emp_compensation
values (1,'salary',10000),(1,'bonus',5000),(1,'hike_percent',10)
, (2,'salary',15000),(2,'bonus',7000),(2,'hike_percent',8)
, (3,'salary',12000),(3,'bonus',6000),(3,'hike_percent',7);
select * from emp_compensation;