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.
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