There is a table of votes with dates. There are many entries in one day. You must select the entries for the last three days or three days before the specific date.
I was going to take the maximum date, for each line, perform a datediff relative to the maximum date, we get a number, and select only those lines for which this datediff returns the value <3.
Can you please tell me if I'm doing the right thing, or is there another way?
The table is quite simple.
create table votes (id int, creationDate datetime, userId int)
select * from table where date_field>getdate()-3- Mike