SQL Query Question

  • Hello everyone,

    Thank you for looking into my question.

    I have a dataset like the below in a table..

    I need to write a query to produce a result like below.

    Anyone has any ideas??

     

     

  • I have some ideas – they involve GROUP BY and MAX(). You have nearly 4,000 points and this is simple stuff. What have you tried so far?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Siva Ramasamy wrote:

    Hello everyone,

    Thank you for looking into my question.

    I have a dataset like the below in a table..

    I need to write a query to produce a result like below.

    Anyone has any ideas??

    Yes... You've been around long enough to know that if you want coded help, that you need to post readily consumable data instead of graphics.  Please read and heed the article at the 1st link in my signature line be for why and one way how to do such a thing.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Phil Parkin wrote:

    I have some ideas – they involve GROUP BY and MAX(). You have nearly 4,000 points and this is simple stuff. What have you tried so far?

    I don't think it is that simple. There are 2 different sections of the initial data table containing Plan 20000479 and 20027778. The OP wants them separated into different sections and not grouped together just by the order he has displayed them. Yet there is nothing in this table to separate the same plan other than the position that they have been displayed in his picture.

    Maybe the OP has forgotten to put in a column.

  • It looks like a packing interval problem.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • drew.allen wrote:

    It looks like a packing interval problem.

    Drew

    I wish I could vote this up more.  Totally agreed on the prognosis and the link.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 6 posts - 1 through 6 (of 6 total)

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