comstring1="SELECT MAGACIN.GBR, MAGACIN.DATA, NOVI.AB, Sum(IIf([sifra]='0992201',[kol],Null)) AS Addblue,Sum(IIf([sifra]='0999001',[kol],Null)) AS Antifriz, Sum(IIf([sifra]='0991000',[kol],Null)) AS Gorivo, Sum(IIf([sifra]='0993050',[kol],Null)) AS Motmaslo, Sum(IIf([sifra]='0992201',[kol],Null))/Sum(IIf([sifra]='0991000',[kol],Null))*100 AS Addbluegorivo FROM MAGACIN INNER JOIN NOVI ON MAGACIN.GBR = NOVI.GBR GROUP BY MAGACIN.GBR, MAGACIN.DATA, NOVI.AB HAVING (((MAGACIN.GBR)=[@gbr1]) AND ((NOVI.AB)=[@ab1] or (NOVI.AB)=[@ab2]) AND ((MAGACIN.DATA)>=[data1] And (MAGACIN.DATA)<=[data2])) ORDER BY MAGACIN.DATA";
comstring2 = "SELECT NALOG1.GBRV, NALOG1.DATA, Min(IIf([NALOG1.GBRV] = [@gbr1] And ((NOVI.AB)=[@ab1] or (NOVI.AB)=[@ab2]) And[NALOG1].[POCKM]>0,[NALOG1.POCKM],Null)) AS pockm, Max(IIf( [NALOG1.GBRV]= [@gbr1] And ((NOVI.AB)=[@ab1] or (NOVI.AB)=[@ab2]) and ([NALOG1.DATA]>=[@data1]) And ([NALOG1.DATA]<=[@data2]),[NALOG1.KRAJKM],NULL)) AS krajkm, (Max(IIf([NALOG1.GBRV]= [@gbr1] And ((NOVI.AB)=[@ab1] or (NOVI.AB)=[@ab2]) and ([NALOG1.DATA]>=[@data1]) And ([NALOG1.DATA]<=[@data2]) ,[NALOG1.KRAJKM],NULL))-(Min(IIf([NALOG1.GBRV] = [@gbr1] And ((NOVI.AB)=[@ab1] or (NOVI.AB)=[@ab2]) And[NALOG1].[POCKM]>0,[NALOG1.POCKM],Null))) ) AS Razlika, Max(NOVI.DATAP) AS Poslprov, Max(NOVI.DATAS) AS Poslserv, Sum(NALOG1.km) AS sumkm, Max(NOVI.KMP1) AS KMP, Max(NOVI.KMS1) AS KMS FROM NALOG1 INNER JOIN NOVI ON NALOG1.GBRV = NOVI.GBR GROUP BY NALOG1.GBRV, NALOG1.DATA HAVING ( ((NALOG1.GBRV)=[@gbr1]) AND ((NALOG1.DATA)>=[@data1] And (NALOG1.DATA)<=[@data2]) )";