troubleshooting Question

Microsoft, Visual Web Developer, 2005, ASP.NET 2.0 SQL Query

Avatar of accessloans
accessloans asked on
.NET ProgrammingASP.NETSQL
4 Comments1 Solution255 ViewsLast Modified:
I am using the following sql query which extracts the companys names from a table and totals the costs in and costs out for that company based on if  the case is completed in the current month and is a specific type of case into a gridview. I want the gridview to also display the total cases that were completed for each company.

SELECT Lender.Company, COALESCE (SUM(Commission.AmountIn), 0) AS InCost, COALESCE (SUM(Commission.AmountOut), 0) AS OutCost
FROM Lender INNER JOIN CaseUnderWriting ON Lender.ID = CaseUnderWriting.LenderID INNER JOIN CaseDetails ON CaseUnderWriting.CaseID = CaseDetails.CaseID INNER JOIN CaseProcessing INNER JOIN Commission ON CaseProcessing.CaseID = Commission.CaseID ON CaseDetails.CaseID = Commission.CaseID
WHERE (MONTH(CaseProcessing.StatusDate) = MONTH(GETDATE())) AND (YEAR(CaseProcessing.StatusDate) = YEAR(GETDATE())) AND (CaseProcessing.StatusID = 22) AND (CaseDetails.LoanTypeID = 8)
GROUP BY Lender.Company
ORDER BY Lender.Company

Contract ERP Admin/Consultant

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 4 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 4 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