How to write query for such case
| Column A | Column B |
| ------------ | ------------ |
| Cell ABC | 1 |
| Cell oo | bb |
| Cell BCD | 2 |
| Cell bb | oo |
I need to meet conditions :
Show me only results of Column A and B when they differs BUT with exception when
Column A = 'oo' and Column B = 'bb' or Column A = 'bb' and Column B = 'oo' i don't want them in my results (they have exception)
Based on this example i expect to see in results only
| | |
| ------------ | ------------ |
| Cell ABC | 1 |
| Cell BCD | 2 |
I tried query
Select * from Table where Column A ! = Column B
but I am stuck with part to exclude when columns have particular values.
2条答案
按热度按时间b4wnujal1#
You can try those conditions :
Which, for the sample data:
Outputs :
Demo here
mrphzbgm2#
You can use the condition to exclude the records and then negate them with
NOT
as follows: