select product.id,product.name,product.itemcode,sum(product.amount)as total_amount
from product where product.account in
select G.account from report_results G
where G.status='Y')
group by product.id,product.name,product.itemcode
Consider the above as QUERY1
Now in order to perform an operation i modified the QUERY1 as below(i am using a new table called proc_temp
(select product.id,product.name,product.itemcode,sum(product.amount)as total_amount
from product where product.account in
(select G.account from report_results G
where G.status='Y'))as Input,proc_temp
where Input.id=proc_temp.id
The above query is not correctly formed.I want to join query1 with a new table proc_temp and compare both of its id column.Please help me in correcting this syntactically.