求一sql语句
表结构如下:
表名student
id(自动增长类型)  name(字符串类型)
1                张三  
2                王二
3                李四
4                张三我想通过一个sql语句查询出来学生的数量,名字相同的为一个学生,即应当查询出来学生的
数量为3个,我通过下面的sql语句语法错误,请大家指正一下
select count(distinct name) from student
我想通过这个语句等到结果是:3,但语法错误

解决方案 »

  1.   

    select count(name) from student  gorup by name
      

  2.   

    select count(distinct id) from student  group by  name
      

  3.   

    select count(distinct name) from student  group by  name 
      

  4.   

     SELECT count( DISTINCT name ) FROM student  你再运行一下 看看 应该不会错!!
      

  5.   

    --取所有名字的总数
    select count( distinct name) from student
    --统计每个名字的数量
    select name, count(*) from student
    group by name
      

  6.   

    select count(name) from student  gorup by name