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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:46:10+00:00 2026-05-25T12:46:10+00:00

I have table a and b. a has order_id and ship_total b has order_id,

  • 0

I have table a and b.

  • a has order_id and ship_total
  • b has order_id, item, qty, and price

How do I query and get the sum of all ship_total on all orders that have a total qty under 100?

I am afraid if I do something like this, it’s going to be wrong.

select SUM(ship_total) FROM a as a inner join b as b on a.order_id=b.order_id WHERE SUM(qty) < 100 GROUP BY a.order_id

Any help would be greatly appreciated!

I’ve tried the answers from below and it’s not adding everything together. It’s giving me the shipping amount from each order.

  • 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-25T12:46:11+00:00Added an answer on May 25, 2026 at 12:46 pm

    One way:

    SELECT
        SUM(A.ship_total)
    FROM
        (SELECT B.order_id FROM B GROUP BY B.order_id HAVING SUM(qty) < 100) SQ
    INNER JOIN A ON
        A.order_id = SQ.order_id
    

    Another way:

    SELECT
        SUM(A.ship_total)
    FROM
        A
    WHERE
        order_id IN (
            SELECT order_id
            FROM B
            GROUP BY order_id
            HAVING SUM(qty) < 100)
    

    Try each out and see which performs best for you.

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

Sidebar

Related Questions

I have a LIST (query output)that has the distinct ID’s from a table Account.
Lets say I have one table called REVIEWS This table has Reviews that customers
I have a table that stores user information. The table has a userid (identity)
I have a lookup table that has a Name and an ID in it.
I have a table that has (for example) 4 columns. pk_table_id INT NOT NULL
I have a table that has a column which holds the id of a
If I have a table that has a TIMESTAMP column, and I want to
I have a table that has the following columns table: route columns: id, location,
I have a table that has a user id & timestamp, like the following.
I have a table that has the user ID already in it, but some

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.