50分,求 一 统计条数的 sql 语句!解决方法

50分,求 一 统计条数的 sql 语句!如题,有如下 数据姓名张三张三张三李四李四想得到的结果是姓名总数张三3

50分,求 一 统计条数的 sql 语句!
如题,有如下 数据

  姓名

  张三
  张三
  张三
  李四
  李四

想得到的结果是

  姓名 总数

  张三 3
  李四 2
 


[解决办法]

SQL code
select 姓名 , count(*) 总数 from tb group by 姓名
[解决办法]
SQL code
create table tb(姓名 varchar(10))insert into tb values('张三') insert into tb values('张三') insert into tb values('张三') insert into tb values('李四') insert into tb values('李四') GOselect 姓名 , count(*) 总数 from tb group by 姓名drop table tb/*姓名         总数          ---------- ----------- 李四         2张三         3(所影响的行数为 2 行)*/
[解决办法]
SQL code
create table tb(姓名 varchar(10))insert into tb values('张三') insert into tb values('张三') insert into tb values('张三') insert into tb values('李四') insert into tb values('李四') GOselect distinct 姓名 , (select count(*) from tb where 姓名=a.姓名) 总数 from tb adrop table tb
[解决办法]
上面都对的 帮顶
[解决办法]
SQL code
create table tb(username varchar(10))insert into tb values('张三') insert into tb values('张三') insert into tb values('张三') insert into tb values('李四') insert into tb values('李四') GOselect username,count(*) 总数 from tb group by username