㈠ sql语句统计人数的问题
接访人数=sum(PtNumber),这里不需要用case语句.
㈡ sql命令语句怎么查询人数
你说的不怎么具体 根据你的字面意思 应该这样查 select count(*) from 表名
㈢ 在sql中怎样查询同一个姓的人数
工具/材料:SQL Server Management Studio、数据表people。
1、首先在桌面上,点击“SQL Server Management Studio”图标。
㈣ SQL语句 求总人数问题
答案是对了是9个,因为你没写名重复的没统计,所以是9个
㈤ sql语句列出sex的人数
这种需要写存储过程了,一条语句是搞不定的,先获取所有sex,然后遍历,获取count值
㈥ 用SQL语句怎么统计人数
select sum(case when 研究生性别=‘男' then 1 else 0 end) / sum(case when 研究生性别=‘女' then 1 else 0 end) from tab 和求出了怎么比
㈦ 如何用一条SQL语句查询出男女个数和已婚个数
select sum(case xb = '男' when 1 else 0 ) as "男人的个数"
sum(case xb= '女' when 1 else 0 ) as "女人"
sum(case yh = '是' when 1 else 0 ) as "已婚个数" from biao
㈧ sql语句统计查询结果数量怎么写
可以通过count函数来实现。
sqlOne:select * from tablename1 where id>5;此语句查询出来多条记录,之后看做一个新的表。
sqlTwo:select conut(*) from (select * from tablename1 where id>5) as tablename2;此语句即可查询出来统计的记录条数。
备注:以上方法通用于所有的数据统计,如果是单表查询,可以直接通过:“select count( *) from tablename1 where id>5"的形式查询出结果。
㈨ SQL语句,统计人数问题。
这样就可以了
seletc count(*) as [人数] from 表 group by name
㈩ 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
分别查询上述五门科目各科的学生名字,返回结果为(科目,学该科目的学生名字)