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

  • SEARCH
  • Home
  • 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 6681435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:35:24+00:00 2026-05-26T04:35:24+00:00

Ok I have two tables. Table IDAssoc has the columns bill_id , year ,

  • 0

Ok I have two tables.

Table IDAssoc has the columnsbill_id, year, area_id.

Table Bill has the columns bill_id, year, main_id, and amount_due.

I’m trying to get the sum of the amount_due column from the bill table for each of the associated area_ids in the IDAssoc table.

I’m doing a select statement to select the sum and joining on the bill_ids. How can I set this up so it will have a single row for each of the associated bills in each area_id from the assoc table. There may be three or four bill_ids associated with each area_id and I need those summed for each and returned so I can use this select in another statement. I have a group by set up for the area_id but it still is returning each row and not summing them up for each area_id. I have the year and main_id specified already in the where clause to return the data that I want, but I can’t get the sum to work properly. Sorry I’m still learning and I’m not sure how to do this. Thanks!

Edit- Basically the query I’m trying so far is basically just like the one posted below:

select a.area_id, sum(b.amount_due)
from IDAssoc a
inner join Bill b
on a.bill_id = b.bill_id
where Bill.year = 2006 and bill.bill_id = 11111

These are just arbitrary numbers.
The data this is returning is like this:
amount_due – area_id
.05 1003
.15 1003
.11 1003
65 1004
55 1004

I need one row returned for each area_id with the amount_due summed. The area_id is only in the assoc table and not in the bill table.

  • 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-05-26T04:35:25+00:00Added an answer on May 26, 2026 at 4:35 am
    select a.area_id, sum(b.amount_due)
    from IDAssoc a
    inner join Bill b
    on a.bill_id = b.bill_id
    where b.year = 2006 and b.bill_id = 11111
    group by a.area_id
    

    You might want to change inner join to left join if one IDAssoc can have many or no Bill:

    select a.area_id, coalesce(sum(b.amount_due),0)
    from IDAssoc a
    left join Bill b
    on a.bill_id = b.bill_id
    where b.year = 2006 and b.bill_id = 11111
    group by a.area_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables suppose table 1 has two columns with short names and
My question is: I have two tables: table A has two columns (KeyA and
Let's say I have two tables: Table 1 has the columns NOTE_ID (a unique
I have two tables in my database: NEWS table with columns: id - the
I have two tables with similar columns - let's say table A with column
I have two tables Table FOO FooUniqueID| Year| Name| Worth| --------------------------- 1 2008 Bob
Let's say I have two tables: Table: Color Columns: Id, ColorName, ColorCode Table: Shape
Suppose I have two tables: Table A has information about the stock holdings of
I have two tables: Table 1 has Episode and Code, with Episode as distinct.
I have two tables Table : 1, Name : NdcAwp, Columns-Ndc, AwpUnitCost Table :

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.