Jump to content

Using SUM With MAX


dlebowski

Recommended Posts

Hi.  I have a table that looks like the following:

 

+------+---------------+

| Price | ItemNumber |

+------+---------------+

| 1      | 33            |

| 2      | 66            |

| 3      | 66            |

| 4      | 44            |

| 5      | 44            |

| 6      | 44            |

+------+---------------

 

What I want to do is takes the highest Price for each ItemNumber, and sum those values.  For example:

 

1 - 33

3 - 66

6 - 44

---------

Total:  10

 

I am assuming that I am going to use MAX function and SUM, but how do I use both.  Here is my query:

 

SELECT MAX(Price), ItemNumber FROM mytable GROUP BY ItemNumber ORDER BY ItemNumber

 

This query gives me this:

 

1 - 33

3 - 66

6 - 44

---------

 

 

So how do I use that same query to give me a SUM of those values?  Than you in advance!

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.