mfrancisp
mfrancisp

Reputation: 119

Join Two Queries Into Columns in a Table

I need help revising the query below. I'm trying to create a table like this:

| Jan 2014 | Feb 2014 |
|   7.5    |    8     |

But I end up getting this:

| Jan 2014 |
|   7.5    |
|     8    |

Is there a way to join these two (possibly more) queries into columns instead of rows? I'm using MS Access by the way. Thank you in advance.

My Current Query:

SELECT * FROM
(SELECT AVG([Length of Service in Years including Partial Year]) AS Jan2014 
 FROM [January 2014 HC] AS A) 
UNION ALL 
(SELECT AVG([Length of Service in Years including Partial Year]) AS Feb2014 
 FROM [February 2014 HC] AS B)

Thanks NoDisplayName for the answer, I think I got it!

EDIT:

 SELECT * FROM
 (SELECT AVG([Length of Service in Years including Partial Year])
 FROM [January 2014 HC] AS A) AS Jan2014, 
 (SELECT AVG([Length of Service in Years including Partial Year]) 
 FROM [February 2014 HC] AS B) AS Feb2014

Upvotes: 0

Views: 31

Answers (1)

Pரதீப்
Pரதீப்

Reputation: 93694

Since both the queries going to return only one row you can do this.

select 
(SELECT AVG([Length of Service in Years including Partial Year]) 
 FROM [January 2014 HC]) AS Jan2014 , 
(SELECT AVG([Length of Service in Years including Partial Year]) 
 FROM [February 2014 HC]) AS Feb2014 

Upvotes: 3

Related Questions