已知表数据如下:
Date |
ID |
Content |
2012-10-25 |
1 |
test |
2012-10-26 |
1 |
test |
2012-10-27 |
1 |
test |
2012-10-28 |
1 |
test |
2012-10-29 |
1 |
test |
2012-11-15 |
1 |
Test2 |
2012-11-16 |
1 |
Test2 |
2012-11-17 |
1 |
Test2 |
2012-11-18 |
1 |
Test2 |
2012-12-11 |
2 |
xx |
2012-12-12 |
2 |
xx |
2012-12-13 |
2 |
xx |
2012-12-14 |
2 |
xx |
2012-2-1 |
3 |
xxx |
2012-2-2 |
3 |
xxx |
2012-2-3 |
3 |
xxx |
2012-2-9 |
3 |
xxxx |
2012-2-10 |
3 |
xxxx |
2012-2-11 |
3 |
xxxx |
根据上表数据,请教一个条sql语句能够查询得到下面的结果:
BeginDate |
EndDate |
ID |
Content |
2012-10-25 |
2012-10-29 |
1 |
test |
2012-11-15 |
2012-11-18 |
1 |
Test2 |
2012-12-11 |
2012-12-14 |
2 |
xx |
2012-2-1 |
2012-2-3 |
3 |
xxx |
2012-2-9 |
2012-2-11 |
3 |
xxxx |
PS:连续日期的ID值和Content值是一样的
做进度管理呢?
select min(date) as startdate ,max(date) as enddate ,id,from tableA group by content,id
谢谢