SQLTeam.com | Weblogs | Forums

Build monthly retention matrix

Hello I need to build a monthly retention matrix using SQL having userID, registration date and paste date

Please provide DDL, sample data and expected results. The description you provided isn't enough information to provide any help

Hi there please look at the sample

Pictures don't help. We need readily consumable DDL, sample data and expected results. Here's a start of what we need, but no idea what you are expecting as a result. Also, you mention userId, but have courier in your pic

create table #t (Id int identity(1,1) not null primary key,
				Courier varchar(20),
				RegDate date,
				LastOrderDate date)

insert into #t values
('Courier1','7/23/2020','9/11/2020'),
('Courier2','5/18/2020','7/16/2020'),
('Courier3','3/7/2020','9/14/2020'),
('Courier4','6/29/2019','5/25/2020'),
('Courier5','4/4/2020','5/8/2020'),
('Courier6','4/12/2019','9/3/2020')

Thank you it means if I insert all those value in the created table will I be able to have the monthly retention result ?

The courier Can be use as ID since it is numbered

I also want to share the excel file but the systems not accepting

I found an article on how to solve that easily please can you help me with this ?

Again, there is nothing you've added that we can use to help you. I provide some DDL and sample data, but you again show another picture. Please use what I gave you to provide what you want. Don't paste pictures, but readily consumable code