Consider the following: SELECT Inonhd.Fac, Inonhd.fpartno, Inonhd.fpartrev, Inonhd.fcudrev, Inonhd.fbinno, Inonhd.flocation, sum(Inonhd.fonhand) as fonhand, Inonhd.flot, Inmast.fdescript, Inmast.fmeasure, Inmast.fstdcost, Inmast.f2totcost, Inmast.flastcost, Inmast.fgroup, Inmast.fprodcl, Inmast.favgcost FROM m2mdata01.dbo.inonhd inonhd INNER JOIN m2mdata01.dbo.inmast inmast ON UPPER(inMast.Fac) = UPPER(Inonhd.Fac) AND UPPER(Inmast.fpartno) = UPPER(Inonhd.fpartno) AND UPPER(Inmast.fRev) = UPPER(Inonhd.fpartrev)
Of course I get the error: SQL Server Database Error: Column 'inonhd.fac' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.Over and over again. However, when I put all those fields in the group by clause I don't get the data I want either. Should I just be doing these sums with a nested query?