㈠ sql语句 求总人数问题
答案是对了是9个,因为你没写名重复的没统计,所以是9个
㈡ sql 求总人数
select count(*) as "总人数" from 表名 where 课程号="002"
㈢ sql查询一个班级中总共有多少人以及男女分别多少人
create view StuClassView as
SELECT s.ID ,s.StuName ,s.StuAge ,s.StuAddress ,s.StuTel ,s.ClassId ,s.StuId,s.StuSex ,e.ClassName,e.ClassInfo,e.ClassFlag
FROM Classes as e left join Students as s on s.ClassId=e.ClassIdselect sc.ClassName as '班级名称',count(sc.StuId) as '总人数' ,sum(case when sc.StuSex='男' then 1 else 0 end) as '男', sum(case when sc.StuSex='女' then 1 else 0 end) as '女' from StuClassView as sc group by sc.ClassName!
㈣ sql一条语句查询总人数和姓周的
你是说姓周的一共有多少人是吗?
select
sum(id)
from
表名
where
字段名
like
'%周%'
㈤ 查询出每个部门的人员总数,sql语句怎么写
sql 使用sum 与 group by
可以统计每个部门的总人数
sum统计总人数 group by根据部门分组
例子
id departmentname number
1 技术 10
2 技术 3
3 销售 50
sql语句
select departmentname ,sum(number)number from table group by departmentname ;
结果
departmentname number
技术 13
销售 50
㈥ sql 统计人数
select count(stu_id) from student where subject in{‘英语’,‘政治’,‘数学’,‘计算机’,‘C语言编程'}
上述SQL语句为查询科目为这五门课的学生总数,如果用count(*),可能没有剔除重复记录,所以用count(stu_id)
select subject, count(stu_id) from student where subject in{‘英语’,‘政治’,‘数学’,‘计算机’,‘C语言编程'} group by subject
分别查询上述五门科目,每门科目的学生总数,返回的是这样的数据对(pair):(英语,50) (政治, 45)……
select distinct name from student where subject in{‘英语’,‘政治’,‘数学’,‘计算机’,‘C语言编程'}
查询选择上述五门课的所有学生名字,必须加上关键词distinct,以除去重复的名字(比如同一个学生可以同时选上述五门课)
select subject, distinct name from student where subject in {‘英语’,‘政治’,‘数学’,‘计算机’,‘C语言编程'}group by subject
分别查询上述五门科目各科的学生名字,返回结果为(科目,学该科目的学生名字)
㈦ 用sql语句完成统计学生的总人数
select * from 表名 这是查到所有数据,
再用一个变量去接收,$xx=select * from
count($xx); 这个是总条数
㈧ 利用sql统计“学生”表中学生的总人数
统计“学生”表中学生的总人数的sql语句是:
select count(*) from student;
其中select代表查询,count(*)是统计行数量,student是学生表,使用上述语句可以统计学生表中的所有行记录也就是学生的总人数。
(8)sql总人数是多少扩展阅读
常用sql语句介绍:
1、 查询指定列
SQL>SELECT empmo, ename, mgr FROM emp;
SQL>SELECT DISTINCT mgr FROM emp; 只显示结果不同的项
2、查询指定行
SQL>SELECT * FROM emp WHERE job='CLERK';
3、使用算术表达式
SQL>SELECT ename, sal*13+nvl(comm,0) FROM emp;
nvl(comm,1)的意思是,如果comm中有值,则nvl(comm,1)=comm; comm中无值,则nvl(comm,1)=0。
SQL>SELECT ename, sal*13+nvl(comm,0) year_sal FROM emp; (year_sal为别名,可按别名排序)
SQL>SELECT * FROM emp WHERE hiredate>'01-1月-82';
㈨ 用T-SQL语句。查询员工总人数
use
库名
select
count(查询的列名)
as
员工总人数
from
员工表名
where
条件
不知道你的表,也不知道你的库,所以无法给出准确的答案