In my query I have the following condition
left Join Table2 on Table2.Id = Table1.Id and Table2.status in ('Close', 'Open')
And the above condition gives me 2 extra rows because of the left join. I noticed that if I have only either Close or Open in the condition it returns the correct number of rows.
To fix that I was trying to write something like this
And Table2.status = (Case Table2.status
WHEN 'Open' Then 'Open'
When 'Close' Then 'Close'
End )
But this still returns 2 extra rows. Any suggestions on how to fix this??
You could do something like this:
This seems pretty hacky, but I cannot seem to come up with something better at the moment. Otherwise, you could use a
DISTINCT