第18章_MySQL8.0的其它新特性课后练习
# 第18章_MySQL8.0的其它新特性课后练习

# 1. 创建students数据表,如下

CREATE DATABASE test18_mysql8;

USE test18_mysql8;

CREATE TABLE students(
    id INT PRIMARY KEY AUTO_INCREMENT,
    student VARCHAR(15),
    points TINYINT
);

#2. 向表中添加数据如下
INSERT INTO students(student,points)
VALUES
    ('张三',89),
    ('李四',77),
    ('王五',88),
    ('赵六',90),
    ('孙七',90),
    ('周八',88);

SELECT * FROM students;

#3. 分别使用RANK()、DENSE_RANK() 和 ROW_NUMBER()函数对学生成绩降序排列情况进行显示
#方式1:
SELECT ROW_NUMBER() over (ORDER BY points DESC) AS "排序1",
       RANK() over (ORDER BY points DESC) AS "排序2",
       DENSE_RANK() over (ORDER BY points DESC) AS "排序3",
       student,points
FROM students;

#方式2:
SELECT ROW_NUMBER() over w AS "排序1",
       RANK() over w AS "排序2",
       DENSE_RANK() over w AS "排序3",
       student,points
FROM students WINDOW w AS (ORDER BY points DESC);

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇