关于sql查询,高手请进!

来源:百度知道 编辑:UC知道 时间:2024/05/22 03:49:56
现在有一张a表:
create table a(
id int identity(1,1),
names varchar(100),
types varchar(100)
)
types字段为类型:其中类型包括:1,2,3 共三种类型

我现在想查询出3种类型中共有多少用户?

共有多少:
select count(id) from a;

各有多少:
select types,count(id) from a group by type;

没明白你的意思。

意思是不是没有表达清楚…三种类型共有多少不就是表中共有多少吗?select count(*) from a,每个类型各有多少的话加个分组就行了,select types,count(*) from a group by types