Interval data

Hello, I want to make a query that will give results like in the picture.
thanks.

periods

hi hope this helps

create data script
-- Create Tables 
create table SQLTeam.TempTable(ID int,Period_1 varchar(10),Period_2 varchar(10),Period_1_Price int,Period_2_Price int) 

----------------------------------------------------------------
-- Insert data Tables

insert into SQLTeam.TempTable select 1,'April','May',12,22
insert into SQLTeam.TempTable select 2,'May','May',13,23
insert into SQLTeam.TempTable select 3,'April','May',14,24

insert into SQLTeam.TempTable select 1,'May','June',15,25
insert into SQLTeam.TempTable select 2,'June','June',16,26
insert into SQLTeam.TempTable select 3,'May','June',17,27
Select 
    'SQL', 
    a.ID,a.Period_1,Period_1_Price,Period_2_Price 
from 
    ( select ID,Period_1,Period_1_Price from SQLTeam.TempTable where Period_1 = 'May' ) a 
       JOIN
    ( select ID,Period_1,Period_2_Price from SQLTeam.TempTable where Period_2 = 'May' ) b 
         on a.ID = b.ID
order by a.id

image

thansk :slight_smile: