How do I sum only 2 columns with a group by that has more columns?
Posted on 2009-12-16
I have a query that inserts these comlumns into another table using a scheduled job but i can't figure out how to get only the rows for Distinct Teacher, TestDate that have > 75 in any hour without including ClassDescription in the grouping.
SELECT DISTINCT [Teacher]
,[Before 7 AM]
GROUP BY [Teacher]
,[ClassDescription] -- Don't want to group by ClassDescription
HAVING (SUM([Before 7 AM]) > 75)
OR (SUM([7 AM]) > 75)
OR (SUM([8 AM]) > 75)
OR (SUM([9 AM]) > 75)
I've been racking my brain for days trying to figure out a differant route to go with this and keep coming back to 'having' Please help!!