sql - How to narrow down count query by a finite time frame? -


i have query identifying more 1 submission user particular form:

select userid, form_id, count(*) table_a group userid, form_id having count(userid) > 1 

however, trying see users submitting more 1 form within 5 second timeframe (we have field submission timestamp in table). how narrow query down criteria?

@nikotromus

you've not provided lot of details schema , other columns available, nor / how , information used.

however if want "live" compare results in time against current timestamp like:

select userid, form_id, count(*)   table_a  datediff(second,yourcolumnwithsubmissiontimestamp, getdate()) <= 5 group userid, form_id having count(userid) > 1 

Comments