这是本人实际的情况,从sql2000数据库中取出一个查询,再从该查询中将厚度转置,如下图中,的0.38 0.76两项就是厚度的两个结果,我按彭大人的说法画个葫芦,但出错了,请指示. 胶片成品 = " round(sum(case when A1.宽 > = IsNull(A1.上底,0) then A1.宽 else A1.上底 end " & _ " * A1.高 * A2.数量*A2.数量级/1000000) , 2) as 胶片面积 "
SQL2 = " select A2.生产日期,A1.厚 , A3.厚度 , " & _ 胶片成品 & ", " & 加大面积 & " " & _ " from 客户原数 A1,胶片使用记录 A2,胶片资料 A3" & _ " where " & DateArr & " and A1.单号=A2.单号 " & _ " and A1.序号=A2.序号 and A2.卷级 is not null " & _ " and A2.卷级=A3.卷号 " & _ " group by A2.生产日期,A1.厚,A3.厚度" SQL3 = Replace(SQL2, "级", "一") & " union " & _ Replace(SQL2, "级", "二") & " union " & _ Replace(SQL2, "级", "三") & " union " & _ Replace(SQL2, "级", "四") strsql = " TRANSFORM SUM(胶片面积) SELECT 厚 FROM (" & SQL3 & ") as A group by 生产日期,厚 PIVOT 厚度 " 'strsql = " TRANSFORM SUM(A.胶片面积) SELECT A.生产日期,A.厚 FROM (" & SQL3 & ") as A group by A.生产日期,A.厚 PIVOT A.厚度 " 两个都有错误提示, 请指点
[此贴子已经被作者于2008-3-3 9:23:53编辑过] |