00thilani wrote:
both have same attributes
Attributes? Do you mean "columns"?
00thilani wrote:
superkeys
I am unfamiliar with that term. Do you mean "primary key"? Or perhaps "foreign key"? Perhaps this will work:
SELECT
curr_val,
Items_Rs - Items_Is AS items_difference,
Amount_Rs - Amount_Is AS difference_amount
FROM (
SELECT curr_val, count(*) AS Items_Rs, SUM(amount) AS Amount_Rs
FROM RECEIVE
WHERE coin_note='n'
GROUP BY curr_val
) AS Received
INNER JOIN (
SELECT curr_val, count(*) AS Items_Is, SUM(amount) AS Amount_Is
FROM ISSUE
WHERE coin_note='n'
GROUP BY curr_val
) AS Issued
ON Issued.curr_val = Received.curr_val
Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog