I need a count of rows where action=1 and action is different from the above row. The first row should count if action=1.
action_date | action
---------------------+--------
2017-01-01 00:00:00 | 1
2017-01-02 00:00:00 | 1
2017-01-03 00:00:00 | 0
2017-01-04 00:00:00 | 0
2017-01-05 00:00:00 | 1
2017-01-06 00:00:00 | 0
2017-01-07 00:00:00 | 1
In this example the 1st, 5th, and 7th rows count and the result should be 3. Any help is much appreciated.