PDA

View Full Version : Help joining queries


Kal
07-16-2008, 05:36 PM
Hi,

I am trying to write a query which gives me a number of deals projected to go live and how many actually went live on a date.

I have the following two queries below which work fine, however I would like to display the results together in threee columns.


SELECT s.ph_projected_live_date, COUNT(s.ph_projected_live_date) AS freq
FROM provisions_history s
WHERE s.ph_projected_live_date != '0000-00-00'
GROUP BY s.ph_projected_live_date

SELECT q.ph_provisioned_date, COUNT(q.ph_provisioned_date) AS freq2
FROM provisions_history q
WHERE q.c_status = 'Live'
GROUP BY q.ph_provisioned_date


ph_projected_live_date, freq, freq2

I am having difficulity in joining the two queries together.

Any help would be great.

Fumigator
07-16-2008, 06:23 PM
Use a UNION ALL. Select a "dummy" column in each query that will only be filled in by the other query.

Kal
07-17-2008, 09:31 AM
Hi,

Doesn't a UNION ALL only give you rows and not columns?

Fumigator
07-17-2008, 05:50 PM
I'm not sure where you're going with that question... yeah it gives you rows, as well as column, but all queries return rows, and columns, so... :confused: