db2

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
supriya
Member
Posts: 7
Joined: Wed Sep 27, 2006 12:19 pm

db2

Post by supriya » Wed Sep 27, 2006 1:00 pm

1) How to find Nth highest salary using co-related subquery?

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Nth highest salary - SQL

Post by Krishna » Wed Sep 27, 2006 2:32 pm

Hi supriya,

Here is the query.

Code: Select all

SELECT     *    FROM        TABLEA  E1
WHERE     N =   (SELECT     COUNT(DISTINCT (E2.SAL))
                            FROM         TABLEA E2
                            WHERE      E2.SAL >= E1.SAL)
 

Thanks,
Krishna

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others