select 名称, 编码,  属性, '次数'=(select count(*) from 表 group by 名称, 编码 ), 备注
from 表

解决方案 »

  1.   

    select 名称, 编码,  属性, '次数'=(select count(*) from 表
    where 名称=a.名称 and 编码=a.编码
     group by 名称, 编码 ), 备注
    from 表 a
      

  2.   

    --应该是实现更新update 表 set 次数=(select count(*) from 表 where 名称=表.名称 and 编码=表.编码)
      

  3.   

    --这个也可以update 表 set 次数=a.次数
    from 表,(select 名称,编码,次数=count(*) from 表 group by 名称,编码) a
    where 表.名称=a.名称 and 表.编码=a.编码
      

  4.   

    --第一个出了点问题,更正!  update 表 set 次数=(select count(*) from 表 where 名称=a.名称 and 编码=a.编码)
      from 表 a/*测试
    名称         编码         属性   次数          备注         
    ---------- ---------- ---- ----------- ---------- 
    我们         wom        01   4           aaa
    我们         wom        02   4           bbb
    我们         wom        03   4           zzz
    我们         wom        04   4           bbb
    我们         wome       04   2           zzz
    我们         wome       06   2           aaa
    我们         women      06   1           aaa(所影响的行数为 7 行)
    */
      

  5.   

    谢谢.didoleo() 的写法存在一个问题,执行过程中出现错误,mschen(老陈)的写法可以.