导航:首页 > 编程大全 > 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数据库统计男女人数相关的资料

热点内容
有的视频文件无法播放 浏览:189
如何关闭同花顺左边的app 浏览:685
上海那个酒店专线网络 浏览:508
macae安装目录在哪个文件夹 浏览:664
微信文件在哪里iphone 浏览:664
医学用书哪个网站 浏览:795
联通拉光纤数据多少网速最好 浏览:502
java删除文档中的字符串 浏览:733
wireshark获取qq密码 浏览:767
java程序设计简答题题答案 浏览:142
mt6737root工具 浏览:835
用什么做数据库缓存 浏览:500
网络上68h32什么意思 浏览:746
javaweb开发源代码 浏览:814
苹果4s取消锁屏密码 浏览:770
不支持文件照片打不开 浏览:516
ps创意作品教程 浏览:333
微信表情小图在哪个文件 浏览:230
wdt配置文件 浏览:689
苹果手机人工客服电话 浏览:784

友情链接