|
我有如下的SQL语句,在QUERY里能正常运行查询,当我把该查询引用到REPORT或FORM是,就出错,而且再到QUERY里运行该查询时,不能运行了.打开DESIGN界面看,该语句已经被自动修改,了.
select a.*,rtrim(iif(isnull(a.Sum_extload),0,round(a.Sum_ExtLoad/b.Sum_ExtLoad*100,2))) +'%' AS LoadPercengage from (select date,[assembly number],[product name],[commodity],sum ([Ext Load]) as Sum_Extload from FPS_Costbom group by date,[assembly number],[product name],[commodity]
union all
select date,[Assembly Number],[product name],'Total',sum([Ext load]) as Sum_ExtLoad from
FPS_COSTBOM group by date,[Assembly Number],[product name]) a inner join (select date,[assembly number],[product name],sum ([Ext Load]) as Sum_Extload from FPS_Costbom group by date,[assembly number],[product name])b ON (a.[Assembly Number]=b.[Assembly Number]) AND (a.date=b.date);
修改后为:
SELECT a.*, rtrim(IIf(isnull(a.Sum_extload),0,round(a.Sum_ExtLoad/b.Sum_ExtLoad*100,2)))+'%' AS LoadPercengage FROM [select date,[assembly number],[product name],[commodity],sum ([Ext Load]) as Sum_Extload from FPS_Costbom group by date,[assembly number],[product name],[commodity] UNION ALL select date,[Assembly Number],[product name],'Total',sum([Ext load]) as Sum_E] AS a INNER JOIN [select date,[assembly number],[product name],sum ([Ext Load]) as Sum_Extload from FPS_Costbom group by date,[assembly number],[product name]] AS b ON (a.date=b.date) AND (a.[Assembly Number]=b.[Assembly Number]);
显然有问题了.
请各位高手帮忙看看有什么问题啊,有没有什么建议.
[em06] |
|