Please Vote This As Helpful if it helps to solve your issue Please Mark This As Answer if it solved your issue
So you can wrap all of these inside procedure for inserting to your main table so that you can capture difference in count inside same script itself to populate the audit table to get your result This has to be part of the insertion logic for the table each day. WHERE DateCOlumn >= CAST(GETDATE() as date)ĪND DateCOlumn = DATEADD(dd,-1,CAST(GETDATE() as date)) So based on that you can identify date of insertion for each row and just do like this to populate the table INSERT TableName (countret,) SELECT SUM(TotalCnt) - SUM(YestCnt) AS countret,CAST(GETDATE() as date) AS
MSDN Support, feel free to contact easy if you've an audit column in your main table which indicates the date of populationĬreate a audit table to capture diff in count for each day If you have any compliments or complaints to This can be beneficial to other community members reading this thread. Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. ROW_NUMBER() OVER (ORDER BY v_date) AS RN Step 2, schedule a job to pull the number of groups on current day into the table insert into calculationīased on the data of table "calculation", we could calculate out this. Step1, create a table to store number of the groups every day. For such request, here are several steps for your reference.