zoukankan      html  css  js  c++  java
  • sql partition by

    --不分班按学生成绩排名
    select *,ROW_NUMBER() over(order by Score desc) as Sequence from Student

    id          Grade       Score       Sequence
    ----------- ----------- ----------- --------------------
    8           3           90          1
    1           1           88          2
    6           2           80          3
    10          3           80          4
    3           1           75          5
    9           3           70          6
    5           2           70          7
    2           1           66          8
    7           2           60          9
    4           2           30          10

    (10 行受影响)

    --分班后按学生成绩排名
    select *,row_number() over(partition by Grade order by Score desc) as Sequence from Student

    id          Grade       Score       Sequence
    ----------- ----------- ----------- --------------------
    1           1           88          1
    3           1           75          2
    2           1           66          3
    6           2           80          1
    5           2           70          2
    7           2           60          3
    4           2           30          4
    8           3           90          1
    10          3           80          2
    9           3           70          3

    (10 行受影响)

    Top
    收藏
    关注
    评论
  • 相关阅读:
    js添加和删除class
    GIT回滚master分支到指定tag版本
    table添加正确的样式
    iframe父页面与子页面赋值
    关于日期转换
    vue-cli脚手架安装
    npm手册
    linear-gradient常用实现效果
    【转载】说说JSON和JSONP,也许你会豁然开朗,含jQuery用例
    雷霄骅走了
  • 原文地址:https://www.cnblogs.com/hualiu0/p/5244179.html
Copyright © 2011-2022 走看看