How to retrieve only the records where stat changes?
问题 I want to get same output: using the following sample data create table x ( id int, date datetime, stat int ) insert into x values (1, '2017-01-01', 100), (1, '2017-01-03', 100), (1, '2017-01-05', 100), (1, '2017-01-07', 150), (1, '2017-01-09', 150), (1, '2017-02-01', 150), (1, '2017-02-02', 100), (1, '2017-02-12', 100), (1, '2017-02-15', 100), (1, '2017-02-17', 150), (1, '2017-03-09', 150), (1, '2017-03-11', 150), (2, '2017-01-01', 100), (2, '2017-01-03', 100), (2, '2017-01-05', 100), (2,