Jump to content

SELECT DISTINCT but get the sum of another column


deansatch

Recommended Posts

I have a table where there are multiple rows per order_number. Each row has a column for price and quantity.

 

I want to show a summary e.g.

order no: 123, qty: 55, total price: £2222

order no: 454, qty: 65, total price: £2652

etc....

 

If I use SELECT DISTINCT I can get the rows as one order number per row, but how can I add the price/quantities for each order instead of just getting the single values for these columns?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.