--测试数据
create table tb(id int identity,shijian int,laiyuan varchar(100))
insert tb select 1,'http://www.3721.com'
union all select 2,'http://www.3721.com/index.htm'
union all select 3,'http://www.3721.com/index/aa.htm'
union all select 4,'http://www.21cn.com/aa/bb/123.asp'
union all select 5,'http://www.3721.com/index/cc/aa.htm'
union all select 6,'http://www.21cn.com'
union all select 7,'http://community.csdn.net/expert/forum.asp'
union all select 8,'http://community.csdn.net/Expert/topic/3549/3549840.xml?temp=.4138147'
go
--查询统计
select 网站=left(laiyuan,charindex('/',laiyuan+'/',8)-1),数量=count(*)
from tb
group by left(laiyuan,charindex('/',laiyuan+'/',8)-1)
go