SQL Query in DB2

db2 sql interview questions

Moderator: Moderator Group

Post Reply
trushant
Member
Posts: 17
Joined: Thu Sep 12, 2013 5:21 pm

SQL Query in DB2

Post by trushant » Sat Apr 05, 2014 2:57 pm

In interview i faced below question:

How to find 10th highest salary in employe table with employe name.

My answer was :shock:

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Apr 06, 2014 5:39 am

Try something like this:

Code: Select all

SELECT EMPSAL FROM EMPNEW E1 WHERE n = 
 (SELECT COUNT(*) FROM EMPNEW E2 
 WHERE E1.EMPSAL<=E2.EMPSAL&#41;; 
In your case n will be 10.

I did not test this, but copied it from another post.
Have a good one

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