Reputation: 141
I'm new to SQL so this took my a long time without being able to figure it out. My table looks like this:
+------+------+------+
|ID |2016 | 2017 |
+------+------+------+
|1 |A |A |
+------+------+------+
|2 |A |B |
+------+------+------+
|3 |B |B |
+------+------+------+
|4 |B |C |
+------+------+------+
I would like to have only the rows which have changed from 2016 to 2017:
+------+------+------+
|ID |2016 | 2017 |
+------+------+------+
|2 |A |B |
+------+------+------+
|4 |B |C |
+------+------+------+
Could you please help ?
Upvotes: 2
Views: 65
Reputation: 556
select * from mytable where column_2016<>column_2017
assuming your column labels are column_2016 and column_2017
Upvotes: 3