筛选数据--插入选课数据

select version();

select now();

select sysdate from dual;

select stuname ,stubirth from tb_student stusex=0;

----查询80后学生的信息----两种方法

select stuname ,stusex,stubirth  from tb_student where

stubirth >='1980-1-1' and stubirth <='1989-12-31'

select stuname ,stusex,stubirth  from tb_student where

stubirth between '1980-1-1' and '1989-12-31'

---查询姓“林”的学生和性别--模糊查询----

select stuname ,stusex from tb_student where stuname like '林%';

select stuname ,stusex from tb_student where stuname like '林_ _';

---查询有“不”的学生和性别--模糊查询----

select stuname ,stusex from tb_student where stuname like '%不%' or stuname like '%嫣%';

%匹配任意个字符,_ 精确匹配字符个数

---查询没有录入家庭地址的学生---处理空值用is,不能用=

select stuname from tb_student where stuaddr  is null;

select stuname from tb_student where stuaddr  is not  null;

---查询学生选课的所有日期(去重)

select distinct scdate from tb_score;

---查询学生的家庭住址(去重)

select distinct stuaddr from tb_student where stuaddr is not null;

---查询男学生的姓名和生日按照年龄从大到小排列(排序)

select stuname ,stubirth from tb_student where stusex=1 order by stubirth desc

select stuname ,year(now())-year(stubirth) as 年龄 from tb_student where stusex=1 order by 年龄 desc

---查询年龄最大的学生的出生日期(聚合函数)

---查询年龄最小的学生的出生日期(聚合函数)

select max (stubirth) from tb_student

select min (stubirth) from tb_student

---查询男女学生的人数---(分组和聚合函数)

select count(*) from tb_student;

select count(stuid) from tb_student;

select stusex,count(stusex) from tb_student group by stusex;

select stusex ,min(stubirth) from tb_student group by stusex;

----查询课程编号为1111的课程的平均成绩

select avg(scmark) from tb_score where couid=1111;

select min(scmark) from tb_score where couid=1111;

select count(scmark) from tb_score where couid=1111;

----先筛选--在分组--在排序---

----查询学号为1001的学生所有的课程的平均分

select avg(scmark) from tb_score where stuid =1001;

select stuid as 学号,avg(scmark) as 平均分 from tb_score group by stuid

---查询年龄大于等于90分的学生的学号和平均成绩

select stuid as 学号,avg(scmark) as 平均分 from tb_score group by stuid having 平均分>=90

---查询年龄最大的学生的姓名和年龄(子查询+运算)/嵌套查询

select  stuname as 姓名,year(now())-year(stubirth) as 年龄 from tb_student where stubirth =(select min(stubirth) from tb_student) ;

---查询选了两门以上课程的学生的姓名(子查询/分组条件/集合运算)

select stuname from tb_student where stuid in (

select stuid from tb_score group by stuid having count (stuid)>2

) ;

---查询学生姓名

import itertools

for val in itertools.permutations("ABCD",2):

print(val)

for val in itertools.permutations("ABCD",'1234'):

print(val)-------笛卡尔积

内查询---外查询---

分页查询----

3.2 从关系型数据库中查询数据相关推荐

  1. Sqoop(三)将关系型数据库中的数据导入到HDFS(包括hive,hbase中)

    本文转自:https://www.cnblogs.com/yfb918/p/10855170.html 一.说明: 将关系型数据库中的数据导入到 HDFS(包括 Hive, HBase) 中,如果导入 ...

  2. flask查询mysql数据展示_flask再学习-思考之怎么从数据库中查询数据在页面展示!...

    看别人视频觉得很简单,要自己做蒙蔽了!这样子.NO! 1. 流程: 首先要有和数据库连接的驱动!一般有PYMySQL mysqlclient 等 使用扩展Flask-SQLAlchemy 获得orm对 ...

  3. 直接从数据库中查询数据生成email附件(excel)

    算是自己做一个记录和备份吧 直接上代码,生成Excel的. 1.ExcelUtil4 package com.vstrong.utils;import java.io.IOException; imp ...

  4. java从mysql中查数据_java怎么从数据库中查询数据并输出

    try { //这里的是MYSQL 举例 //加载驱动 Class.forName("com.mysql.jdbc.Driver"); //创建数据库连接 Connection c ...

  5. mysql查询转json数据库_json格式数据,将数据库中查询的结果转换为json, 然后调用接口的方式返回json(方式一)...

    调用接口,无非也就是打开链接 读取流 将结果以流的形式输出 将查询结果以json返回,无非就是将查询到的结果转换成jsonObject ================================ ...

  6. 如何将存储在MongoDB数据库中的数据导出到Excel中?

    将MongoDB数据库中的数据导出到Excel中,只需以下几个步骤: (1)首先,打开MongoDB安装目录下的bin文件夹,(C:\Program Files (x86)\MongoDB\Serve ...

  7. python查数据库写入excel_【Python】将数据库中的数据查询出来自动写入excel文档...

    近期每天都要监控一个数据. 第一个版本是这样的: 每天新增一个文档来汇总这个数据.这样搞了几天之后,过了一个周末,过来突然发现数据变多了很多,这个时候要调整策略,直接一个文档汇总出要的数据就可以了. ...

  8. python将数据写入excel_【Python】将数据库中的数据查询出来自动写入excel文档

    近期每天都要监控一个数据.第一个版本是这样的: 每天新增一个文档来汇总这个数据.这样搞了几天之后,过了一个周末,过来突然发现数据变多了很多,这个时候要调整策略,直接一个文档汇总出要的数据就可以了. 这 ...

  9. java显示数据库_java查询数据库中的数据并显示

    java查询数据库中的数据并显示 关注:93  答案:2  mip版 解决时间 2021-01-17 16:29 提问者笑低了眉眼 2021-01-17 04:11 button.addSelecti ...

最新文章

  1. 百度地图 key_Android百度地图导航的接入(包含驾车、公交、步行)
  2. JavaScript Binding
  3. 浅谈python socket编程
  4. python数据分析入门
  5. 禅道备份功能_更新禅道燃尽图及数据备份
  6. 一加8 Pro或将配备120Hz刷新率屏幕
  7. 视频编解码(五):解码器驱动代码理解
  8. python2升级python3
  9. ADB工具连接Android手机
  10. 群晖系统ftp服务器,群晖对接云服务器ftp
  11. Mongodb副本集RECOVERING
  12. java标准差代码实现
  13. 6.Paper小结——《A Privacy-Preserving and Verifiable FederatedLearning Scheme》
  14. EndNote: layout can not be formatted because it is no longer open
  15. 海思Hi3519AV100深度学习方案(一)darknet转caffmodel之caffe安装(基于Ubuntu16.04+python3.5+opencv3.4.0+cuda10.0)
  16. 投影机RS-232串口接口大全
  17. 石家庄市学府路机动车科目三考场路线详细教案
  18. android 9.0 toast不显示,9.0 toast定位+WebDriverWait显示等待
  19. vue 3.0 即将发布,敬请期待
  20. 论文阅读笔记 | 三维目标检测——PointRCNN

热门文章

  1. 安卓苹果手机抓取京东cookie
  2. pythoncookie自动登录_Python使用cookie 免密登录了解一下
  3. 64位 Eclipse IDE for Java EE Developers 下载地址
  4. 电子电路学习笔记(6)——电阻的作用
  5. Python进程池apply_async的callback函数不执行的解决方案
  6. 代码生成器-设计心得
  7. freetype 使用小结
  8. Android——在线计算器完整代码
  9. python可视化界面
  10. 多线程的实际应用场景