• Oracle分析函数ntile


        有这么一个需求。将课程的成绩分成四个等级,为学生打A、B、C、D的绩效。

    drop table course purge;
    create table course
    (
      id number,
      grade number
    );
    insert into course values(1,50);
    insert into course values(2,55);
    insert into course values(3,60);
    insert into course values(4,65);
    insert into course values(5,70);
    insert into course values(6,75);
    insert into course values(7,80);
    insert into course values(8,85);
    insert into course values(9,90);
    insert into course values(10,95);
    commit;


    SQL> select id,grade,ntile(4) over(order by grade desc) til from course;
            ID      GRADE        TIL
    ---------- ---------- ----------
            10         95          1
             9         90          1
             8         85          1
             7         80          2
             6         75          2
             5         70          2
             4         65          3
             3         60          3
             2         55          4
             1         50          4
    已选择10行。

  • 相关阅读:
    服务器常用端口
    xml处理类
    水印的代码
    Asp.net常用的51个代码(非常实用)
    poj 2453
    MOD
    LIS(最长上升子序列)
    POJ各题算法分类(转)
    poj 1496&1850
    poj 1423
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/7019007.html
Copyright © 2020-2023  润新知