当前位置: 首页 > news >正文

sql语句练习

一、现有以下两张表:

第一张表名为cust,其表结构如下:

第二张表名为mark,其表结构如下:

1) [5分]请写出计算 所有学生的英语平均成绩的sq|语句。

2) [5分]现有五 个学生,其学号假定分别为11,22,33,44,55;请用一条SQL语句实现列出这五个学生的数学成绩及其姓名、学生地址、电话号码;

3)[5分]查询所有学生的姓名、计算机成绩,按照计算机成绩从高到低排序;

  1. [5分]查询所有总成绩大于240分的学生学号、姓名、总成绩,按照总成绩从高到低排序;

答案:

1、错:select a.name,avg(b.english) from cust a jion mark b on a.studentno=b.studentno
对:select avg(b.english) from cust a jion mark b on a.studentno=b.studentno
2、select a.name,a.address,a.telno from cust a jion mark b on a.studentno=b.studentno where b.studentno in(11,22,33,44,55)
3、select a.name,b.computer from cust a jion mark b on a.studentno=b.studentno order by computer dasc
4、错:select a.studentno,a.name,b.english+b.math+b.computer from cust a jion mark b on on a.studentno=b.studentno where b.(english+math+computer)>240 order by b.(english+math+computer) dasc
对:SELECTa.Studentno,a. NAME,sum(b.math + b.english + b.computer) zcj
FROMcust a
JOIN mark b ON a.Studentno = b.studentno
GROUP BYa.Studentno,a. NAME
HAVINGzcj > 240
ORDER BYzcj DESC;

二、

A.查询姓‘王’的学生的个数;

B. 查询“数学”比“语文”成绩高的所有学生的学号;

C.查询平均成绩大于90分的同学的学号和平均成绩。

三、第三题求平均成绩,不涉及到课程,只需要关联两张表即可

  1. 查询学生信息表中男生一共有多少人

  1. 查询男生成绩中前3名的成绩

  1. 查询男生成绩中排名第3的成绩

http://www.lryc.cn/news/14413.html

相关文章:

  • 广州蓝景—结合chatGPT下的教育模式变化
  • 大数据框架之Hadoop:MapReduce(三)MapReduce框架原理——shuffle机制
  • 4|无线传感器网络与应用|无线传感器网络原理及方法-许毅版|第3章:无线传感器网络通信-3.1协议结构 3.2物理层|青岛科技大学|课堂笔记
  • 关机时,如何控制systemd服务的关闭顺序
  • 关于MySQL镜像构建过程中添加自动初始化数据库
  • CS144-Lab2
  • Linux内核驱动之efi-rtc
  • Java 字符串
  • 麦克风阵列波束基本概念理解
  • JAVA保姆式JDBC数据库免费教程之02-连接池技术
  • 视频片段怎么做成gif图?快试试这2种方法
  • 2.20计算机如何工作
  • [golang gin框架] 5.Cookie以及Session
  • 【牛客刷题专栏】0x0B:JZ3 数组中重复的数字(C语言编程题)
  • js中的隐式类型转换有哪些
  • WuThreat身份安全云-TVD每日漏洞情报-2023-02-17
  • 掌握MySQL分库分表(三)水平分库分表常见策略range、hash
  • CTFer成长之路之CTF中的SQL注入
  • python snap7读写PLC
  • 使用物联网进行智能能源管理的10大优势
  • 工业4.0和工业物联网如何协同工作
  • Python机器学习入门笔记(3)—— 线性回归
  • Java:顶级Java应用程序服务器 — Tomcat、Jetty、GlassFish、WildFly
  • 如何在SpringBoot项目上让接口返回数据脱敏,一个注解即可
  • python 之 海龟绘图(turtle)
  • RT-Thread SPI使用教程
  • shiro使用——整合spring
  • 2023-02-20 leetcode-AccountsMerge
  • 中国高速公路行业市场规模及未来发展趋势
  • 佳能iC MF645CX彩色激光多功能打印机报E302-0001故障码检修