转置一个简单的 Access Table
Transpose a simple Access Table
有人在 SO 上提出了与此类似的问题,但 none 我已经能够将其应用于我的情况。
我创建了这个简单的求和查询来计算我的 2 Tag Core Count
查询中每一列的值的数量:
SELECT Count([CORE_DATA].[TAG NUMBER]) AS [TAG NUMBER],
Count([CORE_DATA].[TAG STATUS]) AS [TAG STATUS],
Count([CORE_DATA].[UNIT NUMBER]) AS [UNIT],
Count([CORE_DATA].[FUNCTIONAL CLASS]) AS [FUNCTIONAL CLASS]
FROM CORE_DATA;
这很好用。除了我的情况,我需要转置结果 table。例如。字段 1 包含上述查询中的列标题 TAG NUMBER, TAG STATUS, UNIT NUMBER and FUNCTIONAL CLASS
,字段 2 包含相应的计数。
您如何才能实现这一目标?
想通了。这对我有用
SELECT 'TAG NUMBER' as [Attribute Value], [TAG NUMBER] as Count
FROM [2 Tag Core Count]
UNION ALL
SELECT 'TAG STATUS' as [Attribute Value], [TAG STATUS] as Count
FROM [2 Tag Core Count]
UNION ALL
SELECT 'UNIT' as [Attribute Value], [UNIT] as Count
FROM [2 Tag Core Count]
UNION ALL
SELECT 'FUNCTIONAL CLASS' as [Attribute Value], [FUNCTIONAL CLASS] as Count
FROM [2 Tag Core Count];
有人在 SO 上提出了与此类似的问题,但 none 我已经能够将其应用于我的情况。
我创建了这个简单的求和查询来计算我的 2 Tag Core Count
查询中每一列的值的数量:
SELECT Count([CORE_DATA].[TAG NUMBER]) AS [TAG NUMBER],
Count([CORE_DATA].[TAG STATUS]) AS [TAG STATUS],
Count([CORE_DATA].[UNIT NUMBER]) AS [UNIT],
Count([CORE_DATA].[FUNCTIONAL CLASS]) AS [FUNCTIONAL CLASS]
FROM CORE_DATA;
这很好用。除了我的情况,我需要转置结果 table。例如。字段 1 包含上述查询中的列标题 TAG NUMBER, TAG STATUS, UNIT NUMBER and FUNCTIONAL CLASS
,字段 2 包含相应的计数。
您如何才能实现这一目标?
想通了。这对我有用
SELECT 'TAG NUMBER' as [Attribute Value], [TAG NUMBER] as Count
FROM [2 Tag Core Count]
UNION ALL
SELECT 'TAG STATUS' as [Attribute Value], [TAG STATUS] as Count
FROM [2 Tag Core Count]
UNION ALL
SELECT 'UNIT' as [Attribute Value], [UNIT] as Count
FROM [2 Tag Core Count]
UNION ALL
SELECT 'FUNCTIONAL CLASS' as [Attribute Value], [FUNCTIONAL CLASS] as Count
FROM [2 Tag Core Count];