急求一个SQL语句 在线等

linzi779 2006-04-27 11:04:44
比如说一个列的内容 http://seek.3721.com/index.htm?coagent=dh ,我只取http://seek.3721.com 用什么函数
...全文
166 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xeqtr1982 2006-04-27
  • 打赏
  • 举报
回复
declare @t table(aa varchar(50),[count] int)
insert into @t select 'http://seek.3721.com/index.htm?',3
union all select 'http://seek.3721.com/index.htmdfdfsg',10
union all select 'http://www.baidu.com/index.htmdfddfdffsg',2
union all select 'http://www.baidu.com/index.ht',5

select left(aa,charindex('/',replace(aa,'//',''))+2) as aa,sum([count]) as 总数 from @t group by left(aa,charindex('/',replace(aa,'//',''))+2)
linzi779 2006-04-27
  • 打赏
  • 举报
回复
比如说表
aa count
http://seek.3721.com/index.htm? 3

http://seek.3721.com/index.htmdfdfsg 10


http://www.baidu.com/index.htmdfddfdffsg 2
http://www.baidu.com/index.ht 5

...................
我要让他的结果是
http://seek.3721.com 总数
http://www.baidu.com 总数
................................


xeqtr1982 2006-04-27
  • 打赏
  • 举报
回复
declare @t varchar(50)
set @t='http://seek.3721.com/index.htm?coagent=dh'
select left(@t,charindex('/',replace(@t,'//',''))+2)
xeqtr1982 2006-04-27
  • 打赏
  • 举报
回复
declare @t varchar(50)
set @t='http://seek.3721.com/index.htm?coagent=dh'
select left(@t,charindex('/',replace(@t,'http://',''))+7)
tianhxk 2006-04-27
  • 打赏
  • 举报
回复
还有其他特征吗??

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧