我需要帮助修改下面的查询。我正在尝试创建一个这样的表:
| Jan 2014 | Feb 2014 |
| 7.5 | 8 |
但我最终得到了这个:
| Jan 2014 |
| 7.5 |
| 8 |
有没有办法将这两个(可能更多)查询连接到列而不是行?我顺便使用MS Access。提前谢谢。
我当前的查询:
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)
感谢NoDisplayName的回答,我想我明白了!
编辑:
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
答案 0 :(得分:3)
由于两个查询只返回一行,你可以这样做。
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