[attach]36888[/attach]
查询:
SELECT 商店号, iif(产品1=yes,"产品1","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品2=yes,"产品2","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品3=yes,"产品3","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品4=yes,"产品4","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品4=yes,"产品4","") AS 产品 FROM 表1;
转置查询:
SELECT 查询.商店号, 查询.产品
FROM 查询
WHERE (((查询.产品)<>""))
ORDER BY 查询.商店号;
或
select * from
(SELECT 商店号, iif(产品1=yes,"产品1","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品2=yes,"产品2","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品3=yes,"产品3","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品4=yes,"产品4","") AS 产品 FROM 表1
UNION ALL SELECT 商店号, iif(产品4=yes,"产品4","") AS 产品 FROM 表1) as a
where a.产品<>"";作者: ynjxw 时间: 2009-3-24 16:18
可能我的情况比较复杂,我的成绩分析表里的除学号外,其他字段的字段名和字段数量都是变化的,每次都不同,请教怎么解决才好。谢谢作者: todaynew 时间: 2009-3-24 16:30