这种类型的题我在面试中遇到过一次
可是你的这个表中每个人的personal like最大个数不确定,我想只有用存储过程了

解决方案 »

  1.   

    这问題每天都有,在CSDN上有几十个!请参考:
    http://www.csdn.net/expert/topic/789/789814.xml?temp=.2048456
      

  2.   

    http://www.csdn.net/expert/topic/769/769259.xml?temp=.8098566
      

  3.   

    楼上的办法好象不行IF EXISTS (SELECT * FROM sysobjects WHERE  name = N'sumstr')
      DROP FUNCTION sumstr
    GO
    CREATE FUNCTION sumstr(@name nvarchar(50))  
    RETURNS nvarchar(3000)
    AS  
    BEGIN
    declare @sumstr nvarchar(3000)
    set @sumstr=''
    select @sumstr=@sumstr+case when @sumstr<>'' then ',' else '' end+[personal like] from aihao where name=@name
    return(@sumstr)
    END
    GO
    select distinct name as 姓名, dbo.sumstr(name) as 个人爱好
    from aihao
    group by name 
    GO
      

  4.   

    谢谢大家, OpenVMS(半知半解)的办法很好用
    准备结帐!
      

  5.   

    to: j9988,你给的方法,我试过,不好用啊