I keep getting this error:
Incorrect syntax near the keyword 'ORDER'.
Basically, I'm trying to find all the rows grouped by email that have a count = 4. I want those 4 to be ordered by the time field so that I can pull the entries in chronological order.
insert into TableB
( qid, rep, time, email, idmarker )
select TOP 2 qid, rep, time, email, idmarker
WHERE email IN
select email FROM
group by email
having COUNT(*) = 4
ORDER BY time