Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Combined Where and having
create table #TempAccount (UserId int, ACID int) insert into #TempAccount values (100, 1), (100, 2), (100, 3), (100, 4), (101, 2), (102, 1), (103, 2), (103, 3), (103, 4) select * from #TempAccount Select USERID,ACID, ROW_NUMBER() over(partition by USERID order by USERID ) as rownumber into #abc from #TempAccount --WHERE rownumber < = 2 and ACID in (2,3) SELECT *,ROW_NUMBER() over(partition by USERID order by USERID ) as rownumber FROM #abc where ACID in (2,3) and having count(rownumber) >=2 --select ACID from #abc where ACID in (2,3) group by ACID HAVING COUNT(ACID) = 2 drop table #TempAccount
run
|
edit
|
history
|
help
0
Window Functions - ROW_NUMBER()
20181CSE0534
repert
Task1
repert
newtable
index fragmentation and how to deal with it
test
db6
self join