AGGREAGATE VALUES LIKE BETWEEN 1 TO 2 LIKE THAT

  • HI

    HOW TO GENERATE A REPORT LIKE THIS

    QUARTER PEOPLE

    1-2 100

    3-4 500

    ------------------------------------------------------------

    THE ACTUAL VALUE IN THE DATABASE [TARGET TABLE] IS

    QUARTER PEOPLE

    1 50

    2 50

    3 0

    4 500

    ------------------------------------------------------------

  • select (quarter - 1) / 2 as half,

    cast(min(quarter) as char(1)) +'-'+ cast(max(quarter) as char(1)),

    sum(people)

    from your_table

    group by (quarter - 1) / 2)

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

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