Sql for previous commits