Help with Group By

  • How do I get from results below to the results at the bottom of this message?

    iddpid cabid stlid joid qty

    1127133252

    2127133852

    3127134052

    412716353

    5127162953

    6127163953

    Trying to get results as:

    iddpid cabid stlid joid qty

    3127134056

    6127163959

  • you want to use MAX() to get the highest values,sum() to add stuff, and group by the items that you want to...well..group by. something like this:

    select

    max(id),dpid,cabid,max(stlid),joid,sum(qty)

    from your table

    group by dpid,cabid,joid

    Rad (3/10/2009)


    How do I get from results below to the results at the bottom of this message?

    iddpid cabid stlid joid qty

    1127133252

    2127133852

    3127134052

    412716353

    5127162953

    6127163953

    Trying to get results as:

    iddpid cabid stlid joid qty

    3127134056

    6127163959

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Perfect, thanks alot

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply