troubleshooting Question

MS SQL SUM

Avatar of pzozulka
pzozulka asked on
Microsoft SQL ServerMicrosoft SQL Server 2005
2 Comments1 Solution376 ViewsLast Modified:
I have attached my code, which produces the following results:

1
1
3
1
1
1
2
1
3
2
1
3
1
2
2
1
1
1
3
1
1
1
1
3
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
6
2
1
1
1
1
1
5
2
2
1
1
1
2
3
2
1
2
1
1
1
2

How do I alter my code to get me the sum of that instead. Basically the correct response I need to get is 98.
SELECT COUNT(DISTINCT J.JobNo)
FROM Jobs J JOIN JobsParties JP ON J.JobNo = JP.JobNo
            LEFT OUTER JOIN JobsPartiesSvc JPS ON JP.JobPartyNo = JPS.JobPartyNo
            LEFT OUTER JOIN Contacts C ON J.OrdContactNo = C.ContactNo
            LEFT OUTER JOIN Firms F ON C.FirmNo = F.FirmNo
            LEFT OUTER JOIN State S ON F.StateNo = S.StateNo
            LEFT OUTER JOIN Invoices I ON J.JobNo = I.JobNo
WHERE J.Status NOT IN (712,812,811) AND I.Original = 1
AND J.JobDate BETWEEN '7/1/08' and '7/15/08'
AND J.BUNo = 11
GROUP BY C.DisplayName, F.FirmName, F.Address, F.City, F.PostCode, S.StateName
ASKER CERTIFIED SOLUTION
bui_trung_hieu

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros