I have multiple queries that gives different results for same product.
for.
One query returns following rows and columns:-
---------------------------------------------
Product Total sales(K units)
category1 30
category2 40
category3 50
Second query returns following
------------------------------
Product Incentives given(in 1000$)
category1 1500
category2 600
category3 400
-----------
This is difficult put this in single query because of different condition used in each query.
From 2 queries I want to get one result like below:-
-------------------------------------------------------
Product Total sales(K units) Incentives given(in 1000$)
category1 30 1500
category2 40 600
category3 50 400
-----------------
Is there a way to do this without using temporary table ?
Assuming you already *have* those two queries, just bring them together using a WITH clause, eg
with
query1 as ( select .... ), -- your existing query1
query2 as ( select .... ) -- your existing query2
select *
from query1, query2
where query1.product = query2.product;
The optimizer will sort it all out for you.