I am not sure how to describe my question (maybe title is not proper).
Here it is:
I have a table like this:
item type stockdate saledate
1 1 2012-11-06 2012-11-05
2 2 2012-11-06 2012-11-07
3 2 2012-11-06 2012-11-05
So, I want to select from the above table.
There are two conditions:
- if the
typeof an item is1, then I anyway show this item - If the
typeof an item is2, but itssaledate >= stockdate, then I show; otherwise, I don’t show
So from the above table, I want to show only item 1 and 2, because item 1 has type of 1, item 2 has type of 2 but its saledate >= stockdate, item 3 cannot be shown because its saledate<stockdate.
How can I write the select query?
I am using MS SQL Server.
The simpliest solution would be,