Results 1 to 4 of 4

Thread: Top-N Analysis in Oracle database

  1. #1
    Join Date
    Jan 2010
    Posts
    51

    Top-N Analysis in Oracle database

    I am developing a mini project of forms and reports in oracle and need to Write a procedure that retrieves all rows from a database table within a sorted form whatever form I would specify. Can you fulfill my expectations through your response and that would be a great help for me develop my project.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Top-N Analysis in Oracle

    Top-N Analysis :
    The task of retrieving rows from top of the table or bottom using particular column is commonly called as a "Top-N Analysis" and this method is used to build the application (java application,form and reports).

    The internal process of Using this method, you can retrieved all rows from the database and the selected data would be filtered using ROWNUM pseudocolumn or RANK function.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Performing Top-N Analysis using ROWNUM

    Using ROWNUM function

    ROWNUM pseudocolumn generates a number as a signal which indicates to oracle database, selects the rows from a table according to set of numbers and return the result after combining each row in relational format.It would be achieved like this-

    SELECT Empno, Ename, Job, Mgr, Hiredate, Sal
    FROM Emp
    WHERE ROWNUM < 6 ORDER BY Sal;


    This query will return the 5 rows in Ascending order of their salaries.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Top-N Analysis using RANK function

    Using RANK():

    Another function that is provided by oracle database through which you can perform top-N analysis. it uses subquery to complete this operation and it takes the following form :

    SELECT Empid, Empname, Job, Mgr, Hire_date, Salary
    FROM

    (SELECT Empid, Empname, Job, Mgr, Hire_date, Salary,
    RANK() OVER
    (ORDER BY SALARY Desc NULLS LAST) AS Emp_Rank FROM Emp ORDER BY SALARY Desc NULLS LAST)
    WHERE Emp_Rank < 6;

Similar Threads

  1. Joins in oracle database
    By Adriana_andros in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 08:53 PM
  2. Dynamic SQL in Oracle database
    By Adriana_andros in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 07:49 PM
  3. Java in oracle 9i database
    By Gerri in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 08:35 PM
  4. Connect to Oracle database using VB 6.0
    By Ariadne in forum Software Development
    Replies: 2
    Last Post: 19-01-2009, 06:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,158,441.33412 seconds with 16 queries