是不是提示数据类型问题?select cast('W5(11)' as varchar(100)) as etclas,right(rtrim(etprod),1),sum(etVAL) from etiliphy where etwhs in (".$whsstr.") and etclas='W5' and etprod like 'W45%-11%' and etqdte=".$edate." group by right(rtrim(etprod),1) order by right(rtrim(etprod),1)union allselect etclas,right(rtrim(etprod),1),sum(etVAL) from etiliphy where etwhs in (".$whsstr.") and etloct in (".$loctstr.") and etqdte='".$edate."' group by etclas,right(rtrim(etprod),1) order by etclas,right(rtrim(etprod),1)
right(rtrim(etprod),1)
union all
select etclas,right(rtrim(etprod),1),sum(etVAL) from etiliphy where
etwhs in ('.$whsstr.') and etloct in ('.$loctstr.') and
etqdte='.$edate.' group by etclas,right(rtrim(etprod),1) order by
etclas,right(rtrim(etprod),1)
在关键字 'union' 附近有语法错误。还是不行啊!
select cast('W5(11)' as varchar(100)) as etclas,right(rtrim(etprod),1) as xxx,sum(etVAL) as yyy from etiliphy where etwhs in (".$whsstr.") and etclas='W5' and etprod like 'W45%-11%' and etqdte=".$edate." group by right(rtrim(etprod),1)union allselect etclas,right(rtrim(etprod),1) as xxx,sum(etVAL) as yyy from etiliphy where etwhs in (".$whsstr.") and etloct in (".$loctstr.") and etqdte='".$edate."' group by etclas,right(rtrim(etprod),1)
) as x
order by etclas,xxx
select cast('W5(11)' as varchar(100)) as etclas,right(rtrim(etprod),1) as xxx,sum(etVAL) as yyy,1 as zzz from etiliphy where etwhs in (".$whsstr.") and etclas='W5' and etprod like 'W45%-11%' and etqdte=".$edate." group by right(rtrim(etprod),1)union allselect etclas,right(rtrim(etprod),1) as xxx,sum(etVAL) as yyy,2 as zzz from etiliphy where etwhs in (".$whsstr.") and etloct in (".$loctstr.") and etqdte='".$edate."' group by etclas,right(rtrim(etprod),1)
) as x
order by zzz,etclas,xxx
where etwhs in ('.$whsstr.') and etclas='W5' and etprod like 'W45%-11%' and etqdte='.$edate.'
group by right(rtrim(etprod),1)
union allselect etclas,right(rtrim(etprod),1),sum(etVAL) from etiliphy
where etwhs in ('.$whsstr.') and etloct in ('.$loctstr.') and etqdte='.$edate.'
group by etclas,right(rtrim(etprod),1)