If future SQL Server will have LAG windowing function, you can simplify the comparison of previous row to current by using LAG
This works now on Postgresql(since 8.4), it already has LAG and LEAD windowing function:
create table log
(
log_id serial primary key,
acct_id int not null,
active boolean not null,
created timestamp not null
);
insert into log(acct_id, active,created)
values
(1,true,'January 1, 2012'),
(1,true,'January 2, 2012'),
(1,false,'January 3, 2012'),
(1,false,'January 4, 2012'),
(1,true,'January 5, 2012'),
(2,false,'February 1, 2012'),
(2,true,'February 2, 2012'),
(2,false,'February 3, 2012'),
(2,true,'February 4, 2012'),
(2,true,'February 5, 2012');
LAG approach is elegantly simpler than ROW_NUMBER and JOIN combo approach:
with merge_prev as
(
select
acct_id, created,
lag(active) over(partition by acct_id order by created) pr_active, -- previous row's active
active sr_active -- second row's active
from log
)
select *
from merge_prev
where
pr_active <> sr_active
Live test: http://sqlfiddle.com/#!1/b1eb0/25
EDIT
LAG is already available on SQL Server 2012: http://sqlfiddle.com/#!6/d17c0/1