导航:首页 > 编程大全 > sql数据库统计男女人数

sql数据库统计男女人数

发布时间:2024-09-29 11:21:51

❶ SQL 数据库中如何统计指定数据的个数 高分急寻

select count(1) from table_name where 姓名1 = 'mary' +
select count(1) from table_name where 姓名2 = 'mary' +
select count(1) from table_name where 姓名3 = 'mary'+
select count(1) from table_name where 姓名4 = 'mary'+
select count(1) from table_name where 姓名5 = 'mary'

select count(*)
from (
select name1 from table_name
union all
select name2 from table_name
union all
select name3 from table_name
union all
select name4 from table_name
union all
select name5 from table_name
) t
where name1='mary'
笨而简单的方法,想一步完成,写个函数吧

❷ 求数据库sql2008语句

1. 查询年龄大于25岁的女学生的学号和姓名。
select 学号,姓名 from 学生 where datediff(year,'出生日期',getdate())>25;
2. 查询学生姓名和出生年份(并给出生年份取别名)
select 姓名,year(出生日期) as '出生年份' from 学生;
3. 统计选修了2号课程的人数
select count(1) from 选课 where 课号='2';
4. 查询选修了2号课程的平均分
select avg(成绩) from 选课 where 课号='2';
5. 统计计算机科学系的学生人数
select count(1) from 学生 where 所在系='计算机科学系';
6. 查询成绩在60到80之间的所有记录(包括60和80)
select * from 选课 where 成绩 between 60 and 80;
7. 查询成绩为85,86或88的记录
select * from 选课 where 成绩 in('85','86','88');
8. 查询年龄不在19到21岁之间的学生姓名和年龄
select 姓名,datediff(year,'出生日期',getdate()) from 学生 where datediff(year,'出生日期',getdate())<19 or datediff(year,'出生日期',getdate())>21;
9. 查询所有不姓王的学生记录
select * from 学生 where 姓名 not like '王%';
10. 查询所有姓王,且名字只有两个字的学生名字
select 姓名 from 学生 where left(姓名,1)='王' and LEN(TRIM(姓名))=2;
11. 查询所有课程名是“db_”开头的课程名字
给出信息应该缺一个课程表
12. 以系别和年龄从大到小的顺序查询学生表中的全部记录
select * from 学生 order by 所在系 desc,出生日期 asc;
13. 查询姓名的第二个字为“小”字的女生信息
select * from 学生 where 性别='女' and SUBSTRING(姓名,2,1)='小';
14. 查询成绩最高的三个学生的学号和成绩(取前几条数据用“top 数字”)
select top 3 学号,成绩 from 选课 order by 成绩 desc;
15. 查询学生的成绩信息,先按学号升序排序,再按成绩降序排序。
select * from 选课 order by 学号 asc,成绩 desc;

❸ SQL数据库的问题,请问怎么样查询所有性别女的

我来帮你写吧,上的代码有问题。我已经测试好了,通过比较慢,你等等

阅读全文

与sql数据库统计男女人数相关的资料

热点内容
ps做成图片后怎么弄成文件 浏览:689
左侧导航栏css代码 浏览:952
钉钉传送文件最大多少兆 浏览:126
app下载哪里最全 浏览:599
word如何画大箭头 浏览:245
word批量转pdf工具21注册机 浏览:546
打印文档文件3000字需要多少钱 浏览:239
泊车助手app 浏览:147
pscs6完全自学教程 浏览:461
文件夹去不掉只读属性 浏览:203
qq怎么接收文件夹 浏览:35
javahashmapvalues 浏览:548
鼠标选定不了文件内容是坏了么 浏览:589
打开excel标准模板文件名 浏览:798
该文件名字不包含扩展名 浏览:565
华为备份文件 浏览:368
批量删除cpp文件代码注释的工具 浏览:312
下列哪些不属于可编程逻辑器件 浏览:963
苹果6p跳屏是什么原因 浏览:383
下载文件路径是什么 浏览:852

友情链接