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 7901161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:09:05+00:00 2026-06-03T09:09:05+00:00

I hit this issue regularly but here is an example…. I have a Order

  • 0

I hit this issue regularly but here is an example….

I have a Order and Delivery Tables. Each order can have one to many Deliveries.

I need to report totals based on the Order Table but also show deliveries line by line.

I can write the SQL and associated Access Report for this with ease ….

SELECT xxx 
    FROM 
        Order 
    LEFT OUTER JOIN 
        Delivery on Delivery.OrderNO = Order.OrderNo

until I get to the summing element. I obviously only want to sum each Order once, not the 1-many times there are deliveries for that order.

e.g. The SQL might return the following based on 2 Orders (ignore the banalness of the report, this is very much simplified)
Region  OrderNo    Value    Delivery Date
North   1          £100     12-04-2012
North   1          £100     14-04-2012
North   2          £73      01-05-2012
North   2          £73      03-05-2012
North   2          £73      07-05-2012
South   3          £50      23-04-2012

I would want to report:

Total Sales North - £173
    Delivery 12-04-2012
    Delivery 14-04-2012
    Delivery 01-05-2012
    Delivery 03-05-2012
    Delivery 07-05-2012

Total Sales South - £50
    Delivery 23-04-2012

The bit I’m referring to is the calculation of the £173 and £50 which the first of which obviously shouldn’t be £419!

In the past I’ve used things like MAX (for a given Order) but that seems like a fudge.

Surely there must be a regular answer to this seemingly common problem but I can’t find one.

I don’t necessarily need the code – just a helpful point in the right direction.

Many thanks,

Chris.

  • 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-03T09:09:06+00:00Added an answer on June 3, 2026 at 9:09 am

    A roll up operator may not look pretty. However, it would do the regular aggregates that you see now, and it show the subtotals of the order. This is what you’re looking for.

    SELECT xxx 
        FROM 
            Order 
        LEFT OUTER JOIN 
            Delivery on Delivery.OrderNO = Order.OrderNo
    GROUP BY xxx
    WITH ROLLUP;
    

    I’m not exactly sure how the rest of your query is set up, but it would look something like this:

    Region  OrderNo    Value    Delivery Date
    North   1          £100     12-04-2012
    North   1          £100     14-04-2012
    North   2          £73      01-05-2012
    North   2          £73      03-05-2012
    North   2          £73      07-05-2012
    NULL    NULL       f419     NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am beginning with HSQLDB, but I hit this issue and can't figure out
I have been working on this issue for a few days now and can't
This issue was tested, and occurs, in the dev mode (Eclipse...). I have one
This issue is driving me mad. I have several tables defined, and CRUD stored
This issue seems trivial, but I can't get it to work properly. I'm calling
I have 2 questions on this My code always seems to hit a 401
I realize there are several topics about this issue, but none provides a working
I'm having this issue when I hit Run on the simulator/device, the project compiles
I've been searching for a while for an explanation to this issue but getting
All this might look too trivial but read it through - I have simple

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.