Re: Combine 2 queries
dear Dahlia D,
you can combine these 2 queries using "union" or "union all"
I suggest you to add constant/static extra column (e.g. remark as shown bellow ) in both queries to describe the row coming from which query(1st or 2nd) i shown bellow by using you query:
SELECT count(`Lead ID`) AS `Mktg Prospects w Sales Action`, `Region` , 'q1' as remark
FROM `reporting`.`kpi1`
Where `Department` = "Sales" AND `Lead Source` = "Marketing Generated" AND `Status` IN ("Converted to Contact Only","Converted to Opportunity","Dead Lead","Returned to Marketing")
AND `Last modified date` > "2010-08-31"
GROUP BY `Region`, remark
union
SELECT count(`Lead ID`) AS `Mktg Prospects Accepted by Sales`, `Region`, 'q2' as remark
FROM `reporting`.`kpi1`
Where `Department` = "Sales" AND `Lead Source` = "Marketing Generated" AND `Status` IN ("Converted to Contact Only","Converted to Opportunity")
AND `Last modified date` > "2010-08-31"
GROUP BY `Region`, remark
in above query you might not need remark column in group by clause.
in output remark column having "q1" value coming from first and "q2" from second query.
may this help you
Subject
Views
Written By
Posted
2362
February 16, 2011 10:11AM
Re: Combine 2 queries
1188
April 02, 2011 09:17AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.