数据分组范围
2009-12-11 10:09 清海扬波 阅读(247) 评论(0) 编辑 收藏 举报![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
declare @t table(value varchar(10))
insert @t
select 'F000001'
union all
select 'F000002'
union all
select 'F000003'
u nion all
select 'F000004'
union all
select 'F000006'
union all
select 'F000007'
union all
select 'F000008'
union all
select 'F000009'
union all
select 'F000010'
select min(value)+'-'+max(value)
from @t
group by right(value,6)/5
insert @t
select 'F000001'
union all
select 'F000002'
union all
select 'F000003'
u nion all
select 'F000004'
union all
select 'F000006'
union all
select 'F000007'
union all
select 'F000008'
union all
select 'F000009'
union all
select 'F000010'
select min(value)+'-'+max(value)
from @t
group by right(value,6)/5
有时候很复杂的东西能够做出来,反而比较简单的却想不出来解决办法。
这个是网上看到的,感觉很有意思。至少能够在自己绞尽脑汁的时候想想是不
是还有其他简单的解决办法。