Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:14:44+00:00 2026-06-16T03:14:44+00:00

I am a novice trying to work through this here with no luck so

  • 0

I am a novice trying to work through this here with no luck so far, any help is greatly appreciated!!!

Select Distinct
   (AB.agency_no || '-' || ab.branch_no) AS "AGENCY-BRANCH",
   count (AB.agency_no || '-' || ab.branch_no) AS Occurences,
   A.AGY_NAME AS AGENCY,
   Sum(AB.annual_premium) as Premium
 From Agency_Book_View AB, Agency A, Branch B
 Where AB.agency_no = A.Agency_No
   AND B.EXPIRATION_DATE = TO_DATE('12-31-2078', 'MM-DD-YYYY')
   AND B.EFFECTIVE_DATE <= sysdate and b.effective_date >=sysdate - 364
 Group by AB.agency_no || '-' || ab.branch_no, A.Agy_Name, ab.annual_premium
 Order by AB.agency_no || '-' || ab.branch_no

So I am trying to return total annual premium per “agency-branch” and I am getting multiple occurrences of agency-branch. I am trying to get one line per agency branch. I hope this is clear. I tried to include a result set but wasnt allowed to include a picture in my post.

Thanks very much!

Brad

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:14:45+00:00Added an answer on June 16, 2026 at 3:14 am

    Try this :

    SELECT (AB.agency_no || '-' || AB.branch_no) AS "AGENCY-BRANCH",
        COUNT(AB.agency_no || '-' || AB.branch_no) AS Occurences,
        A.AGY_NAME AS AGENCY,
        SUM(AB.annual_premium) AS Premium
    FROM Agency_Book_View AB, Agency A, Branch B
    WHERE AB.agency_no = A.Agency_No AND AB.branch_no = B.branch_no
      AND B.EXPIRATION_DATE = TO_DATE('12-31-2078', 'MM-DD-YYYY')
      AND B.EFFECTIVE_DATE <= SYSDATE AND B.effective_date >= SYSDATE - 364
    GROUP BY AB.agency_no || '-' || AB.branch_no, A.Agy_Name
    ORDER BY AB.agency_no || '-' || AB.branch_no
    

    I joined B table and AB table, removed the DISTINCT and the GROUPed BY ab.annual_premium.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL novice here. I'm trying to get a list of invoice numbers. There are
I'm a novice programmer and I'm trying to learn Android coding using Eclipse. This
I am an absolute programming novice trying to work with some csv files. Though
I'm a Java beginner, trying to get this to work in Eclipse. However, the
I am a novice R user trying to work with a data set of
Hello all I am trying to work through (learn) MVC3 and I was playing
I'm a JavaScript novice trying to build a basic share button as a learning
I'm an encryption novice trying to pass some values back and forth between systems.
I am novice to python and I am trying to understand a basic error
I apologize for the novice question but I'm trying to get oriented with OpenJDK.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.