/ *9. Write a SQL query to retrieve loan number, customer first name, customer last name,
property address, and bankruptcy attorney name. I want all the records that have the
same attorney name to be together, then the customer last name in order from Z-A
(ex.Customer last name of Wyatt comes before customer last name of Anderson)*/
Select LoanNumber,CustomerFname,CustomerLname,Propertyaddress,BankruptcyAttorneyName
From Loan
Group BY BankruptcyAttorneyName,LoanNumber,CustomerFname,CustomerLname,Propertyaddress
Order by
LTrim(Reverse(Left(Reverse(CustomerLname), CharIndex(' ', Reverse(CustomerLname))))) Desc,
CustomerLname Desc -- Fall-over for when there isn't a last name
Is it right comment?
simple