Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: aneeshattingalPosted on 2007-10-18 at 14:50:09ID: 20104973
for current months use this
SELECT Lender.Company, COUNT(Status.STATUS) AS [Completed Cases] FROM CaseDetails INNER JOIN CaseProcessing ON CaseDetails.CaseID = CaseProcessing.CaseID INNER JOIN Status ON CaseProcessing.StatusID = Status.ID INNER JOIN CaseUnderWriting ON CaseDetails.CaseID = CaseUnderWriting.CaseID INNER JOIN Lender ON CaseUnderWriting.LenderID = Lender.ID
WHERE CaseProcessing.StatusDate > = CONVERT(varchar(6), Getdate(),112) +'01'
AND (CaseDetails.LoanTypeID = 8) AND (Status.STATUS = 'COM') OR (CaseDetails.LoanTypeID = 9) AND (Status.STATUS = 'COM')
GROUP BY Lender.Company
ORDER BY Lender.Company
Inorder to include the previous month's records
SELECT Lender.Company, COUNT(Status.STATUS) AS [Completed Cases] FROM CaseDetails INNER JOIN CaseProcessing ON CaseDetails.CaseID = CaseProcessing.CaseID INNER JOIN Status ON CaseProcessing.StatusID = Status.ID INNER JOIN CaseUnderWriting ON CaseDetails.CaseID = CaseUnderWriting.CaseID INNER JOIN Lender ON CaseUnderWriting.LenderID = Lender.ID
WHERE CaseProcessing.StatusDate > = DATEADD(m, -1,CONVERT(varchar(6), Getdate(),112) +'01' )
AND (CaseDetails.LoanTypeID = 8) AND (Status.STATUS = 'COM') OR (CaseDetails.LoanTypeID = 9) AND (Status.STATUS = 'COM')
GROUP BY Lender.Company
ORDER BY Lender.Company