2021-03-02

select * from Student t where t.s_name like '王%';

SELECT COUNT(s_name) '学生的姓名' from Student WHERE s_name LIKE '王%';

SELECT s_name,COUNT(s_name) '出现的次数' FROM Student GROUP BY s_name HAVING COUNT(s_name) < 0;

SELECT s_name,COUNT(s_name) '出现的次数' FROM Student GROUP BY s_name HAVING s_name LIKE '王%';

-- from on jion where GROUP BY having SELECT DISTINCT ORDER BY LIMIT;

SELECT * from Score;

SELECT SUM(s_score) FROM Score WHERE c_id = '02';

SELECT * FROM Student;

SELECT * FROM Course;

SELECT * from Score;

SELECT count(DISTINCT(s_id)) from Score;

-- SELECT DISTINCT *  from Score;

--

SELECT * from Student t WHERE t.s_id in (SELECT DISTINCT(s_id) FROM Score);

SELECT c_id,MAX(s_score) FROM Score GROUP BY c_id;

SELECT

*

FROM

Course c

LEFT JOIN (

SELECT

c_id,

MAX( s_score ),

MIN(s_score)

FROM

Score

GROUP BY

c_id

) s ON s.c_id = c.c_id;

SELECT * FROM Course;

SELECT c_id,count(c_id) from Score GROUP BY c_id;

SELECT * from Student;

SELECT

a.s_sex,a.partition,b.total

FROM

(SELECT s_sex,COUNT(s_sex) As 'partition' FROM Student GROUP BY s_sex) a

(SELECT COUNT(s_sex) As 'total' FROM Student) b

SELECT

s_sex,

n,

ROUND( n / s * 100, 4)

FROM

(

SELECT

*

FROM

( SELECT s_sex, count( 1 ) n FROM Student GROUP BY s_sex ) t1

INNER JOIN ( SELECT count( 1 ) s FROM Student ) t2 ON 1 = 1

)a;

SELECT s_id,AVG(s_score) from Score GROUP BY s_id HAVING AVG(s_score) > 60;

SELECT s_id,COUNT(c_id) FROM Score GROUP BY s_id HAVING COUNT(c_id) >2;

SELECT s_name,COUNT(s_name) FROM Student GROUP BY s_name HAVING COUNT(s_name) =2;

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 建表create table student(s_id string,s_name string,s_birth ...
    VincentLeon阅读 1,369评论 0 0
  • 表名和字段 –1.学生表 Student(s_id,s_name,s_birth,s_sex) –学生编号,学生姓...
    友人A_b238阅读 1,432评论 0 0
  • SQL笔试题50道答案整理 CREATE TABLE Student ( s_id VARCHAR(20), s...
    程序媛_阅读 3,647评论 0 0
  • 相关精彩专题链接:数据成就更好的你 一、数据源 1.学生表 Student(s_id,s_name,s_birth...
    南宫逸痕阅读 3,237评论 0 7
  • 推荐指数: 6.0 书籍主旨关键词:特权、焦点、注意力、语言联想、情景联想 观点: 1.统计学现在叫数据分析,社会...
    Jenaral阅读 11,028评论 0 5

友情链接更多精彩内容