select right(域名,len(域名)-charindex('@',域名)),  count(*),sum(数量) from tb1
group by right(域名,len(域名)-charindex('@',域名))

解决方案 »

  1.   

    select right(emai,len(emai)-charindex('@',emai))域名,count(*)数量 
    from tb1 group by right(emai,len(emai)-charindex('@',emai))
      

  2.   

    select 
      substring(email,charindex('@',email),len(email)) as 域名,
      count(1) as 数量
    from tb1
    group by substring(email,charindex('@',email),len(email))
      

  3.   

    ---测试数据---
    if object_id('[tb1]') is not null drop table [tb1]
    go
    create table [tb1]([email] varchar(17))
    insert [tb1]
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]' union all
    select '[email protected]'
     
    ---查询---
    select 
      substring(email,charindex('@',email),len(email)) as 域名,
      count(1) as 数量
    from tb1
    group by substring(email,charindex('@',email),len(email))
    ---结果---
    域名                数量          
    ----------------- ----------- 
    @126.com          3
    @21cn.com         1
    @hotmail.com      1
    @sina.com         2
    @sohu.com         1
    @yahoo.com.cn     1(所影响的行数为 6 行)
      

  4.   

    我用这个查询出来了结果,但是有一问题,出现重复的域名,如下:1.163.com
    126.com
    sina.com
    qq.com
    hotmail.com
    yahoo.com.cn
    sohu.com
    21cn.com
    tom.com
    2.163.com 
    yahoo.com
    gmail.com
    eyou.com
    sina.com.cn
    msn.com
    263.net
    sina.com 第二个163.com域名比第一域163.com的域名多了个空格。
    我在数据里也没有查询到有空格
    我也用replace修改过了,但是就是修改不过来。但是一统计还是会出现重复的域名。
      

  5.   

    用len和unicode函数看看两个有什么不一样的比如select unicode('
    163')返回的是13,你可以看看所谓的空格是什么字符然后用函数char(编码)来replace掉