14,326,871 members
Rate this:
See more:
Hi Frds I have three tables one is employee Detail,another is salary detail and other is salary given details..

Table 1:Employee Detail

Emp_Id Emp_Name
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 J
10 K

Table 2: Salary_Allocation
Emp_Id Salary_Month Salary_Amount
1 Jan 10000
2 Jan 9000
3 Jan 9000
4 Jan 9000
5 Jan 9000
6 Jan 9000
7 Jan 9000
8 Jan 8000
9 Jan 8500
10 Jan 8500
1 Feb 11000
2 Feb 10000
3 Feb 10000
4 Feb 10000
5 Feb 9500
6 Feb 9500
7 Feb 9500
8 Feb 8500
9 Feb 9000
10 Feb 8500

Table 3:Salary_Deposit

Emp_Id Salary_Month Salary_Deposit

1 Jan 10000
2 Jan 9000
3 Jan 7000
4 Jan 7000
5 Jan 7000
6 Jan 9000
7 Jan 7000
8 Jan 6000
9 Jan 6500
10 Jan 6500
1 Feb 9000
2 Feb 8000
3 Feb 8000
4 Feb 10000
5 Feb 7500
6 Feb 7500
7 Feb 9500
8 Feb 8500
9 Feb 7000
10 Feb 8500

by comparing above three tables ...I want to know which employee for which month how much salary is pending...

I need output as follows

Emp_Id Salary_Month Salary_Pending

3 Jan 2000
4 Jan 2000
5 Jan 2000
7 Jan 2000
8 Jan 2000
9 Jan 2000
10 Jan 2000
1 Feb 2000
2 Feb 2000
3 Feb 2000
5 Feb 2000
6 Feb 2000
9 Feb 2000
Posted
Zoltán Zörgő 11-Jul-12 8:13am

Any progress?
itsureshuk 11-Jul-12 8:51am

Ya working Thanks

Rate this:

## Solution 1

Supposing that there is only one record per employee per month, this one should work:
```select e.*, a.Salary_Amount - d.Salary_Deposit as Salary_Pending
from
Employee_Detail e ,Salary_Allocation a, Salary_Deposit d
where
e.Emp_id = a.Emp_id
and
e.Emp_id = d.Emp_id
and
a.Salary_Month = d.Salary_Month
and
a.Salary_Amount - d.Salary_Deposit <> 0```