Skip to content
Advertisement

Combining the results of two SQL queries as separate columns

I have two queries which return separate result sets, and the queries are returning the correct output.

How can I combine these two queries into one so that I can get one single result set with each result in a separate column?

Query 1:

SELECT SUM(Fdays) AS fDaysSum From tblFieldDays WHERE tblFieldDays.NameCode=35 AND tblFieldDays.WeekEnding=?

Query 2:

SELECT SUM(CHdays) AS hrsSum From tblChargeHours WHERE tblChargeHours.NameCode=35 AND tblChargeHours.WeekEnding=?

Thanks.

Advertisement

Answer

You can aliasing both query and Selecting them in the select query
http://sqlfiddle.com/#!2/ca27b/1

SELECT x.a, y.b FROM (SELECT * from a) as x, (SELECT * FROM b) as y
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement