Ok, yesterday I asked a question and got a great answer. I am back for more help and gosh do I need it!!!
Yesterdays question here : Yesterday's Question - had to do with Sum and Distinct functions
-The link is to another question within this site
Today I am adding to the results an address for each row that is returned, the problem is that when I return an address I am finding that people have entered them differently ex. 123 Main ST. or 123 Main Street etc. The question is am I able to pull only the most recent version or single occurrence of said address and still sum premiums as I have successfully done in the link above?
Here is what I have and its not working:
Select (Agency_Book_View.agency_no || '-' || Agency_Book_View.branch_no) AS "AGENCY-BRANCH",
Agency.Agy_Name,
SUM(Agency_Book_View.annual_premium) AS Premium,
Branch.Mail_Address1,
Agency_Book_View.effective_date
from Branch
INNER JOIN Agency_Book_View
on Branch.Agency_No = Agency_book_view.agency_no
INNER JOIN Agency
on Branch.Agency_No = Agency.agency_no
INNER JOIN Comp_Agy on Branch.Agency_No = comp_agy.agency_no
WHERE COMP_AGY.expiration_date = TO_DATE('12-31-2078','MM-DD-YYYY')
Group by (Agency_Book_View.agency_no || '-' || Agency_Book_View.branch_no),
Agency.Agy_Name,
Branch.Mail_Address1,
Agency_Book_View.Effective_Date
Order by (Agency_Book_View.agency_no || '-' || Agency_Book_View.branch_no)
Result
Again, I truly appreciate any and all help!!!
Brad