I have this query being generated at runtime:
For some reason, the 1 that I add as a row number makes the rest of the query sum/count the values twice, i.e twice bigger numbers are added to table IT3.Code:SELECT 1 as red, " VKUPNO" AS UnvierzitetFakultet, Sum(IIf([TAB]=11 And [RED]=1,[K1],0)) AS Se, Sum(IIf([TAB]=11 And [RED]=1,[K2],0)) AS zeni, Sum(IIf([TAB]=11 And [RED]=1,[K1],0))-Sum(IIf([TAB]=11 And [RED]=1,[K2],0)) AS Mazi, Sum(IIf([TAB]=5 And [RED]=2 Or [TAB]=6 And [RED]=2,[K1],0)) AS [Doktor po Nauki], Sum(IIf([TAB]=5 And [RED]=3 Or [TAB]=6 And [RED]=3,[K1],0)) AS [Magistri po Nauki], Sum(IIf([TAB]=5 And [RED]=4 Or [TAB]=6 And [RED]=4,[K1],0)) AS Specijalisti, Sum(IIf([TAB]=5 And [RED]=5 Or [TAB]=6 And [RED]=5,[K1],0)) AS [So visoko obrazovanie], Sum(IIf([TAB]=5 And [RED]=1 Or [TAB]=6 And [RED]=1,[K3],0)) AS [so polno rabotno vreme], Sum(IIf([TAB]=5 And [RED]=1 Or [TAB]=6 And [RED]=1,[K5],0)) AS [so pokratko rabotno vreme] INTO IT3 FROM Fakulteti INNER JOIN Vnes ON [Fakulteti].[RBR]=[Vnes].[RBR] GROUP BY 1, " VKUPNO";
Any ideas what happens in this case?
Why that 1 at the top confuses the Access SQL engine?
Tried replacing 1 with 0. Then the values of the new row were all zeroes for some reason. As if that column has some influence on the calculation.




Reply With Quote
