我在处理年度报表的时候,需要把每个月的物料详情展示出来,一共14个列,一共十二个月。然后在帆软报表查询所有的时候,会一直报内存超过阈值这个情况,一直查不出来。大概有两三万的数据。sql语句我是用左连接了12个不同条件的主表,有什么简单的办法吗?sql语句如下(因为太长了,所以删减了一部分展示字段):SELECT A.INMCU, A.INFY, trim(A.INLITM), A.Inaisl, trim(O.IMDSC1) AS IMDSC1, trim(O.IMDSC2) AS IMDSC2, trim(O.IMALN) AS IMALN, trim(O.Imstkt) AS IMSTKT, trim(O.IMUOM1) AS IMSTKT, SUM(b.INTQCT), SUM(b.INAPYC), SUM(b.innq01), SUM(b.inan01), SUM(B.INAN01A), SUM(b.INNQ02), SUM(b.INAN02), SUM(b.INNQ03), SUM(b.INAN03), SUM(b.innq04), SUM(b.inan04), SUM(b.INNQ05), SUM(b.INAN05), SUM(b.INNQ06), SUM(b.INAN06), SUM(b.innq07), SUM(b.inan07), SUM(b.INNQ08), SUM(b.INAN08), SUM(b.INNQ09), SUM(b.INAN09), SUM(b.INNQ10), SUM(b.INAN10), SUM(d.innq01), SUM(d.inan01), SUM(e.innq01), SUM(e.inan01), SUM(F.innq01), SUM(F.inan01), SUM(G.innq01), SUM(G.inan01), SUM(H.innq01), SUM(H.inan01), SUM(M.innq01), SUM(M.inan01), SUM(I.innq01), SUM(I.inan01), SUM(J.innq01), SUM(J.inan01), SUM(K.innq01), SUM(K.inan01), SUM(L.innq01), SUM(L.inan01), SUM(N.innq01), SUM(N.inan01) FROM PRODDTA.F5541116 A left join (select * from proddta.f5541116 where inpn='1' and infy='19') b on a.inlitm=b.inlitm AND A.Inaisl=b.Inaisl and a.inpn=b.inpn left join (select * from proddta.f5541116 where inpn='2' and infy='19') d on a.inlitm=d.inlitm AND A.Inaisl=D.Inaisl and a.inpn=d.inpn left join (select * from proddta.f5541116 where inpn='3' and infy='19') e on a.inlitm=E.inlitm AND A.Inaisl=e.Inaisl and a.inpn=e.inpn left join (select * from proddta.f5541116 where inpn='4' and infy='19') F on a.inlitm=F.inlitm AND A.Inaisl=F.Inaisl and a.inpn=F.inpn left join (select * from proddta.f5541116 where inpn='5' and infy='19') G on a.inlitm=G.inlitm AND A.Inaisl=G.Inaisl and a.inpn=G.inpn left join (select * from proddta.f5541116 where inpn='6' and infy='19') H on a.inlitm=H.inlitm AND A.Inaisl=H.Inaisl and a.inpn=H.inpn left join (select * from proddta.f5541116 where inpn='7' and infy='19') M on a.inlitm=M.inlitm AND A.Inaisl=M.Inaisl and a.inpn=M.inpn left join (select * from proddta.f5541116 where inpn='8' and infy='19') I on a.inlitm=I.inlitm AND A.Inaisl=I.Inaisl and a.inpn=I.inpn left join (select * from proddta.f5541116 where inpn='9' and infy='19') J on a.inlitm=J.inlitm AND A.Inaisl=J.Inaisl and a.inpn=J.inpn left join (select * from proddta.f5541116 where inpn='10' and infy='19') K on a.inlitm=K.inlitm AND A.Inaisl=K.Inaisl and a.inpn=K.inpn left join (select * from proddta.f5541116 where inpn='11' and infy='19') L on a.inlitm=L.inlitm AND A.Inaisl=L.Inaisl and a.inpn=L.inpn left join (select * from proddta.f5541116 where inpn='12' and infy='19' ) N on a.inlitm=N.inlitm AND A.Inaisl=N.Inaisl and a.inpn=N.inpn LEFT JOIN PRODDTA.f4101 O ON A.INLITM=O.IMLITM WHERE A.INFY='19' group by A.INMCU, A.INFY, A.INLITM, A.Inaisl, O.IMDSC1, O.IMDSC2, O.IMALN, O.Imstkt, O.IMUOM1