Oracle Analytic function Ntile

Source: Internet
Author: User

There is a need to divide the performance of the course into four grades for students to play 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 rows have been selected.

Oracle Analytic function Ntile

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.