T
TeeSee
I just happened to read the last post with the same name and learned
about the "GROUP BY" query. I am enclosing my SQL and have the
following questions. This is a trial DB with four tblSapDown2006
records and two unique tblMaterialMaster.LocalGroup categories.
SELECT tblMaterialMaster.SISItemCode AS tblMaterialMaster_SISItemCode,
tblMaterialMaster.LocalGroup, tblMaterialMaster.[Material description],
tblSapDown2006.SISItemCode AS tblSapDown2006_SISItemCode,
Sum(tblSapDown2006.LineDollars) AS SumOfLineDollars
FROM tblMaterialMaster INNER JOIN tblSapDown2006 ON
tblMaterialMaster.SISItemCode = tblSapDown2006.SISItemCode
GROUP BY tblMaterialMaster.SISItemCode, tblMaterialMaster.LocalGroup,
tblMaterialMaster.[Material description], tblSapDown2006.SISItemCode;
When I create the "group by" query GROUP BY is initially in each field
of the total line in the grid. I obviously changed that to "sum" in the
LineDollars field. If I lremove "group by" from any of the fields I get
an error. So I think I have three questions.......
1) What is actually happening when I run the query? Is it grouping by
the left most field and working to the right. I don't want grouping in
all fields.
2) How do I change the SQL in oder to group by "LocalGroup"?
3) Why does "material description" have [] brackets when other fields
from same table do not?
Looking forward to replies. Best regards.
about the "GROUP BY" query. I am enclosing my SQL and have the
following questions. This is a trial DB with four tblSapDown2006
records and two unique tblMaterialMaster.LocalGroup categories.
SELECT tblMaterialMaster.SISItemCode AS tblMaterialMaster_SISItemCode,
tblMaterialMaster.LocalGroup, tblMaterialMaster.[Material description],
tblSapDown2006.SISItemCode AS tblSapDown2006_SISItemCode,
Sum(tblSapDown2006.LineDollars) AS SumOfLineDollars
FROM tblMaterialMaster INNER JOIN tblSapDown2006 ON
tblMaterialMaster.SISItemCode = tblSapDown2006.SISItemCode
GROUP BY tblMaterialMaster.SISItemCode, tblMaterialMaster.LocalGroup,
tblMaterialMaster.[Material description], tblSapDown2006.SISItemCode;
When I create the "group by" query GROUP BY is initially in each field
of the total line in the grid. I obviously changed that to "sum" in the
LineDollars field. If I lremove "group by" from any of the fields I get
an error. So I think I have three questions.......
1) What is actually happening when I run the query? Is it grouping by
the left most field and working to the right. I don't want grouping in
all fields.
2) How do I change the SQL in oder to group by "LocalGroup"?
3) Why does "material description" have [] brackets when other fields
from same table do not?
Looking forward to replies. Best regards.