I have 2 tables:
Query_Rates (Actually this is the result of a query):
Unit |
R_Date |
Sold_Rate |
A |
24-AUG-15 |
145 |
B |
21-AUG-15 |
133 |
X |
25-AUG-15 |
200 |
Sent till date:
Unit |
R_Date |
Sold rate |
A |
24-AUG-15 |
142 |
A |
24-AUG-15 |
145 |
X |
25-AUG-15 |
190 |
When I run the query:
Code:
SELECT Query_Rates.*
FROM Query_Rates LEFT JOIN [Sent till date] ON (Query_Rates.R_Date = [Sent till date].[R_date]) AND (Query_Rates.Unit = [Sent till date].Unit)WHERE abs([Sent till date].[Sold rate]-[Query_Rates].[Sold_Rate])>1
I get the following result:
Unit |
R_Date |
Sold_Rate |
A |
24-AUG-15 |
145 |
X |
25-AUG-15 |
200 |
So what I want is a list of all the records from the Query_Rates table where the absolute differences between the sold rates between Query_Rates & [Sent till date] (matching the unit # and the dates) is greater than 1 and the record shouldn't be displayed if it is already present in the [Sent till date] table. But if you notice the first record which has unit A is already mentioned in the "Sent till date" table and shouldn't be repeated again in the query result.
The desired out put should be:
Unit |
R_Date |
Sold_Rate |
X |
25-AUG-15 |
200 |