0% found this document useful (0 votes)
43 views

SQL Interview Questions4

The document discusses SQL interview questions and answers including finding the nth highest salary from a table, displaying records within a range, odd/even numbered records, date functions that return numbers, and deleting duplicate rows.

Uploaded by

Anonymous S5fcPa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

SQL Interview Questions4

The document discusses SQL interview questions and answers including finding the nth highest salary from a table, displaying records within a range, odd/even numbered records, date functions that return numbers, and deleting duplicate rows.

Uploaded by

Anonymous S5fcPa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

12/1/2016 SQLInterviewQuestions

Express To Learn (Home/) Health Tips


(Health-Tips/)
Home (Home/) RDBMS (RDBMS/) SQL (SQL/) PL/SQL (PLSQL/)

Data Warehouse (Data-Warehouse-Introduction/) Informatica (Transformations/) ODI (ODI-Interview-Questions/)

UNIX (UNIX/) Contact Us (Contact-Us/) Blog (http://blog.baji.co.in/)


<<Previous Next>>
(SQL4/) (SQL41/)
Find out nth highest salary from EMP table?

SELECT DISTINCT a.sal from EMP a WHERE


&n=(SELECT count(DISTINCT(b.sal)) from emp b WHERE a.sal <= b.sal);

Display the records between two ranges?

SELECT rownum, empno, ename from emp where rowid in


( SELECT rowid from emp where rownum <=&upto minus SELECT rowid from emp where rownum
<&start).

Display Odd/even number of records?

ODD : SELECT * from emp where (rowid,1) in (SELECT rowid, mod(rownum,2) from emp);
EVEN: SELECT * from emp where (rowid,0) in (SELECT rowid, mod(rownum,2) from emp);

Which date function returns number value?

MONTHS_BETWEEN()

How many ways u can replace query result null value with a text?

2 ways.
Using NVL () function and SET NULL text;

How will you delete duplicate rows from a base table?

DELETE FROM <table_name> WHERE ROWID NOT IN (SELECT MAX (ROWID) FROM <table_name>
GROUP BY <column_name>);
Or
DELETE FROM <table_name> A WHERE ROWID > (SELECT MIN (ROWID) FROM <table_name> B WHERE
B.table_no= A.table_no);

<<Previous
Next>>
(SQL4/)
(SQL41/)
2016 baji.co.in Free
(http://api.hostinger.in/redir/159
(http://baji.co.in)
Sourceofthecontentisgatheredfrommultiplesourcesontheweb.Ownerisnotresponsibleforanyfalseorincorrectinformation,ifanycorrectionneededtothecontentreportitinthecontactus(ContactUs/)
[email protected]

http://baji.co.in/SQL5/ 1/1

You might also like