My code is like shown below :
select col1,count(col2) as col7
from --some join operation
group by col1
having col7 >= 3 -- replace col7 by count(col2) to
U can use this code:
IF OBJECT_ID('tempdb..#temp') is not null DROP TABLE #temp
-- Create tempurary table
CREATE TABLE #temp (Id BIGINT IDENTITY(1,1), col1 BIGINT, countOfcol2 BIGIN)
--insert from the table 2 #temp
INSERT INTO #temp (col1,countOfcol2)
select col1,count(col2) as col7
from --some join operation
select col1,countOfcol2 from #temp
group by col1
having countOfcol2 >= 3 -- replace col7 by count(col2) to make the code work