Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to filter out rows where one column does not equal another on a row?

$
0
0

How can I craft a select statement such that only those rows whose values in two particular columns are different will be returned?

I have a table that, simplified, looks sort of like this, which in this example only those rows in which RT1 and RT2 are different are to be returned:

RId   RT1    RT2
31     62      62       -- Want this row
33     29      29       -- And this one
33     29     229      -- Not this one
34     27     227      -- Not this one


Richard Lewis Haggard


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>