Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Some challenging queries, difficult 4 me !!

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-05 : 16:23:24
sagar writes "Hello friends,
I m a newbie to SQL and came across the following queries, quite tough for me, woking hard on it. Could u pass on the solutions (if u have them ???) and the explanation for the same ??? Glad if u could, Thanx in advance.

Write SQL queries for the following :
------------------------------------
1. Give the range of missing Empno :
Table Emp :
Empno
1
5
9
12
19
The expected output is supposed to be :
2-4
6-8
10-11
13-18
* Assume the data is not sorted
[Hint : Self join ]

2. Write a Delete statement to delete Duplicate records
[Hint : Self join or SubQuery ]

3. Table Bank :
Dr Cr
5000 3000
6000 2000
5000 4000
Display should be as follows :

Balance (Dr - Cr)
-------
2000
6000
7000

The output should be as Cumulative Balance.

4. Display the OVERALL 5th largest Salary from the emp table
[Hint : a subquery or selfjoin ]

5. Display the maximum and the second maximum salary from Emp table

First Second
----- ------
10000 9000

6. Display the experience of the employees in years, months and days till date the query should take care of leap years and should return the
actual data"
   

- Advertisement -