用SQL语言从现有的数据库里根据性别属性分别统计出男女相应的一个属性里各类型的数量

2025-02-25 03:40:31
推荐回答(2个)
回答1:

现过几次 2出现过几次
select count(1) from table1 where A=1;
select count(1) from table1 where A=2;
select [1]=count(case when A=1 then 1 else null end),[2]=
(case when A=1 then 1 else null end) from table1
A为1、B为2的情况几次,
select count(1) from table where a=1 and b=2
当A为1,B出现几次 等等
select count(distinct B ) from table1 where A=1

回答2:

select grider,EnglishEducation,count(*) from table group by grider,EnglishEducation