0

我试图找到我试图在 Access 中解决的问题的答案。我可以从我的输入电子表格中检索以下数据:

Recid Cat1 Cat2 Cat3

1 是 是 否

2 是 是 是

3 否 是 否

4 是 是 否

5 否 否 是

我想创建一个新表,其中仅包含 recid 和具有“yes”作为值的关联类别。

Recid 类别
1 Cat1
1 Cat2
2 Cat1
2 Cat2
2 Cat3
3 Cat2
4 Cat1
4 Cat2
5 Cat3

你能帮我么?提前致谢!

4

1 回答 1

0

您可以使用UNION ALL查询将列数据转换为行:

select recid, cat1 as Category
from yourtable
where cat1 = 'Yes'
union all
select recid, cat2 as category
from yourtable
where cat2 = 'Yes'
union all
select recid, cat3 as category
from yourtable
where cat3 = 'Yes'
于 2013-04-27T22:31:43.033 回答