crosstf
asked on
How to comine like fields in MS SQL
I have the following query from a stored procedure, and I want to combing the ShortDescrption value in the counts by the names listed in the where clause so that it counts all Approved as one count for example, instead of several. How do I do that?
select
(select Count(1) LoanCount from @SummaryReportBasic),
ShortDescription ,
LoanAmount = sum(loanamount),
CountofLoan from @SummaryReportBasic
where shortdescription in ('Approved', 'Approved and awaiting Esign and/Or Certification', 'Certified and Ready for Disbursement','Pending','On Hold','Approved but Cancelled', 'Cancelled/Withdrawn', 'Denied')
Group by shortdescription, CountofLoan
Order by shortdescription
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, was able to obtain the solution.
ASKER
--------------------------
21 Approved 10000 1
21 Approved 34081 4
21 Approved 356423 23
21 Approved and awaiting 10001 1
21 Approved and awaiting 11555 2
21 Approved and awaiting 247156 25
21 Approved and awaiting 351008 31
21 Approved but Cancelled 10000 1
21 Cancelled/Withdrawn 124345 9
21 Cancelled/Withdrawn 1569556 128
21 Certified and Ready 16104 1
21 Certified and Ready 47503 4
21 Certified and Ready 77621 9
21 Denied 687166 51
21 Pending 5990 1
21 Pending