0% found this document useful (0 votes)
21 views5 pages

Database Interview Frequently Asked Queries

The document contains 7 questions about writing SQL statements to perform various data analysis and manipulation tasks on sample tables. The questions cover topics like selecting the 5th largest value, finding maximum and second maximum values, deleting duplicate rows, identifying ranges of missing numbers, calculating running balances, converting numbers to words, and more.

Uploaded by

Aditya Kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

Database Interview Frequently Asked Queries

The document contains 7 questions about writing SQL statements to perform various data analysis and manipulation tasks on sample tables. The questions cover topics like selecting the 5th largest value, finding maximum and second maximum values, deleting duplicate rows, identifying ranges of missing numbers, calculating running balances, converting numbers to words, and more.

Uploaded by

Aditya Kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ASSORTED

1. Create Emp table containing a Sal column with the following sample data:-

EMP
------
SAL
------
8000
7000
6000
5000
10000
9000
4000
8000
7000

Write a SELECT statement to display the Overall 5th largest Sal.


Assuming the above data, the Overall 5th largest Sal would be 6000. Do not make use
of Rownum.

2. For the above table, write a SELECT statement to display the Largest and Second
largest Sals (next to each other). Your output should be as below:-

FIRST SECOND
-------- ------------
10000 9000

Sameer Dehadrai Page: 1


3. Create Emp table containing an Empno column with the following sample data:-

EMP
-------
EMPNO
-----------
1
1
2
3
3
4
4
4
5
6

Write a DELETE statement to delete the duplicate rows. After running your Delete
statement, one occurrence of each value of Empno should remain in the table.

Sameer Dehadrai Page: 2


4. Create Emp table containing an Empno column with the following sample data:-

EMP
-------
EMPNO
-----------
5
9
1
14
25
20

Write a SELECT statement to display the range of missing numbers. Your output
should be as follows:-

MISSING
------------
2–4
6–8
10 – 13
15 – 19
21 – 24

Don’t assume that the existing data in the table is sorted.

Sameer Dehadrai Page: 3


5. Create Bank table containing Deposit and Withdrawal columns with the following
sample data:-

BANK
---------
DEPO WITHD
-------- ----------
5000 3000
6000 5000
4000 2000

Write a SELECT statement to display the cumulative running Balance (Deposit –


Withdrawal). Your output should be as below:-

Balance
----------
2000
3000
5000

6. Write a SELECT statement to display the experience of all the employees (Sysdate –
Hiredate). Your output should be as follows:-

5 years 7 months 11 days


9 years 3 months 16 days
etc.

Don’t assume that there are 365 days in a year or that there are 30 days in a month.
Your solution should even take care of leap years.

Sameer Dehadrai Page: 4


7. Write a SELECT statement to achieve Number to Word conversion. You have to spell
out the Salaries of all the employees. Your solution should work up to Rs. 5 million.
Ignore paise.

Sameer Dehadrai Page: 5

You might also like