Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table User and another Transaction. In Transaction table i have referenced UserId as foreign key. In transaction i have another column named status(which is basically Enum). Now I need those users which have more than two entries in transaction with status 3.
this is what I have Tried
SQL
Select * from Users U
Inner Join Transaction T On U.Id=T.UserId 
having(Count (C.Status =1 ) >2)


Can anyone help
Thanks
Posted

Try
SQL
Select U.id from Users U
Inner Join Transaction T On U.Id = T.UserId
where T.status = 3
group by U.Id, T.status
having Count(T.status ) > 2
 
Share this answer
 
v4
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900