I want to filter a query based on a conditional condition, for example if ProjectId equals 1 then filter based on some condition otherwise, another diffrerent condition:
something that- if possible in SQL- would look like this:
SELECT * FROM [dbo].[Commits]
WHERE CASE WHEN ProjectId=1 THEN (CommitsCount > 2) ELSE (Name LIKE 'R%') END
Example:
ProjectId Name CommitsCount
----------- --------- -----------
1 Ahmed 2
1 Ahmed 6
2 Kamel 10
3 Rami NULL
The result I need from the query is:
ProjectId Name CommitsCount
----------- --------- -----------
1 Ahmed 6
3 Rami NULL