Grouping Numbers - IE 100000 and 119000 etc

  • Hi

    I need to produce a report that groups and then reports on particular number sets.

    How do you group number sets such as:

    0 <= 999,999
    1,000,000 <= 1,190,000
    >= 1,190,001 +

    I would appreciate any help in this matter.

    Brian

    Thanks Brian

    You are never an expert, you are always learning!
  • divide your numbers, e.g. by 10,000, take the integer of the result and group by that.

  • Why not just use a case statement? ie:

    SELECT

      CASE WHEN (X < 100) THEN 1

      WHEN (X >= 100 AND X < 1000) THEN 2

      ELSE 3 END [MyColumn]

    ...

    GROUP BY

    CASE WHEN (X < 100) THEN 1

      WHEN (X >= 100 AND X < 1000) THEN 2

      ELSE 3 END

    Something like that at least...

  • Thanks that worked!!

    Thanks Brian

    You are never an expert, you are always learning!

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

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