To create a sql script so that it keeps information of all the user’s badge swipe in the last 30 days only and truncates the rest of the data.

Question

We need to find the data for each users for their only last 30 days.

For e.g , two A,B men join the company in Jan 2020 and they swipe badge every for in/out. All in/out swipe timing has stored in ‘Swipe date’ column. After some time A left the company in march 2020 end(his period of term is from 1 jan 2020 to 31 march 2020) and B still working in same company.

Now we need to find the last 30 days records for each user then

A and their data from 1 march 2020 to 31 march 2020

B and their data from 1 June 2020 to 30 June 2020

 

UserId FirstName LastName BadgeId Swipe Date
A Alan Troy 8384 6/22/2020
A Alan Troy 8384 6/20/2020
B Brayan Tose 8293 6/22/2020
D Danny Rose 3920 5/1/2020
D Danny Rose 3920 5/15/2020
D Danny Rose 3920 6/1/2020
C Charlie Hanes 9200 6/12/2020
in progress 0
vinod.k 55 years 0 Answers 753 views Member 0

Leave an answer

Browse
Browse