M
Mommybear
I have a database that has 1 record per each item. I want to combine these
and only list the total. I have the following SQL statement.
SELECT DISTINCT JHC.Department, JHC.[Dept Desc], JHC.[Room Title],
JHC.[Equip Code No], JHC.[Plan Room], JHC.[Room No], JHC.Room,
JHC.Description, JHC.[Equip Category], Sum(JHC.[Exist Amt]) AS [SumOfExist
Amt], Sum(JHC.[New Amt]) AS [SumOfNew Amt], JHC.[Unit Cost], JHC.[Prime Mfg],
JHC.Model
FROM JHC
GROUP BY JHC.Department, JHC.[Dept Desc], JHC.[Room Title], JHC.[Equip Code
No], JHC.[Plan Room], JHC.[Room No], JHC.Room, JHC.Description, JHC.[Equip
Category], JHC.[Unit Cost], JHC.[Prime Mfg], JHC.Model
HAVING (((Sum(JHC.[Exist Amt]))>0))
ORDER BY JHC.[Equip Code No], JHC.[Plan Room];
This works great, however, on some of my records, they have different "Equip
Categories" but I still want them to be counted.
Here is an example of my data (For simplicity reasons, I removed some data
from my example):
Department Room Equip Code No Room No Equip Category Exist Amt
admin 5 B1234 504 30A
1
admin 5 B1234 504 30A
1
admin 5 B1234 504 0
1
ED 2 B1234 124 30A
1
The Equip Cat is printed as a Header record.
These should print on the report as:
admin 5 B1234 504
3
ED 2 B1234 124
1
but is printing as:
admin 5 B1234 504
2
admin 5 B1234 504
1
ED 2 B1234 124
1
When I remove JHC.[Equip Category], from the Group By, I get an error saying
it is not a part of the aggregate function. This SQL was written from using
the Design View. Any help would be wonderful as I really need to get this
report done today.
and only list the total. I have the following SQL statement.
SELECT DISTINCT JHC.Department, JHC.[Dept Desc], JHC.[Room Title],
JHC.[Equip Code No], JHC.[Plan Room], JHC.[Room No], JHC.Room,
JHC.Description, JHC.[Equip Category], Sum(JHC.[Exist Amt]) AS [SumOfExist
Amt], Sum(JHC.[New Amt]) AS [SumOfNew Amt], JHC.[Unit Cost], JHC.[Prime Mfg],
JHC.Model
FROM JHC
GROUP BY JHC.Department, JHC.[Dept Desc], JHC.[Room Title], JHC.[Equip Code
No], JHC.[Plan Room], JHC.[Room No], JHC.Room, JHC.Description, JHC.[Equip
Category], JHC.[Unit Cost], JHC.[Prime Mfg], JHC.Model
HAVING (((Sum(JHC.[Exist Amt]))>0))
ORDER BY JHC.[Equip Code No], JHC.[Plan Room];
This works great, however, on some of my records, they have different "Equip
Categories" but I still want them to be counted.
Here is an example of my data (For simplicity reasons, I removed some data
from my example):
Department Room Equip Code No Room No Equip Category Exist Amt
admin 5 B1234 504 30A
1
admin 5 B1234 504 30A
1
admin 5 B1234 504 0
1
ED 2 B1234 124 30A
1
The Equip Cat is printed as a Header record.
These should print on the report as:
admin 5 B1234 504
3
ED 2 B1234 124
1
but is printing as:
admin 5 B1234 504
2
admin 5 B1234 504
1
ED 2 B1234 124
1
When I remove JHC.[Equip Category], from the Group By, I get an error saying
it is not a part of the aggregate function. This SQL was written from using
the Design View. Any help would be wonderful as I really need to get this
report done today.