I have this table in my DB:
ID userID MovieID Rank
1 1 1 9
2 1 2 9
3 1 3 9
4 2 1 9
5 2 2 10
and I want to query it to get mutual movies between 2 users which they rated the same.
for example, in this case, movieID = 1 is rated with '9' by both user 1 and user 2.
so I want to get in the result only the movie 1.
--UPDATE--
so I came up with this (thanks to @RJ1990)
SELECT MovieID
FROM LoverMovie
WHERE (LoverID = 1) OR
(LoverID = 2)
GROUP BY MovieID
HAVING (COUNT(*) > 1) AND (ABS(MAX(Rank) - MIN(Rank)) < 3)
Is this kind of query coule be written with EF (DbContext)?