学生信息表:StudentTbl
 StudentNo   Name   
     1       张三
     2       张三
     3       旺旺
     4       月亮请问如何写查询语句来
求得 有相同名字的学生人数?

解决方案 »

  1.   

    select name,count(1) from StudentTbl
    group by name
    having count(1)>1
      

  2.   

    create table StudentTbl(StudentNo int,  Name   varchar(10))
        insert into StudentTbl select  1      , '张三'
            insert into StudentTbl select  2       ,'张三'
             insert into StudentTbl select 3       ,'旺旺'
            insert into StudentTbl select  4       ,'月亮'select name,count(*) as 出现次数 from StudentTbl
    group by name
    having count(*)>1
    drop table StudentTbl ------------------------
    name      出现次数张三 2还有什么问题欢迎帖出来~