August 15, 2009 at 2:32 pm
How do I obtain a sum of a field, when I have multiple records for the same item? Specifically, the Exceptions table has multiple rows that contain the same InspectionID, how do I sum up the total of all DmgTotal for a unique InspectionID? (SQL Server 2005) (I am a beginner at SQL).
Exceptions table contains the following fields:
InspectionID, DmgTotal
Data Sample:
Row#InspectionIDDmgTotal
#19000120.00
#2900059.00
#3900042.00
#49001400.00
#59002500.00
#69002250.00
#7900330.00
#8900340.00
The result I would like to get is:
InspectioniDTOTAL
9000179.00
9001400.00
9002750.00
900370.00
August 15, 2009 at 2:56 pm
Look up SUM and GROUP BY in the SQL Books Online (SQL Help file, press F1 in management studio to open)
If you can't get it right, post what you have and I'll help you fix it.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 15, 2009 at 4:13 pm
Thanks, I got it.:-P
August 16, 2009 at 8:33 am
Excellent. 🙂
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply