Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2013
    Posts
    3

    Unanswered: Alternative to Case Statement

    I have a table in Oracle DB withe order count and unique IDs as columns:

    Order Count ID
    2 1
    3 2
    4 4
    4 5
    11 6
    20 8
    35 9
    19 12
    Now I want to get a count of IDs grouped by order and separated into different buckets. For e.g. all the orders that have value <= 10 ,I need to separate the order bucket by "1" and all the orders that have value >10 and <100 I need to separate the order bucket by 10.

    The output for above table should be:
    Count(ID) Order
    1 2
    1 3
    2 4
    3 11-20
    0 21-30
    1 31-40

    I don't want to use case statement since I have a lot of such bucket based on which I need to group the data.

    Please suggest how can I write the SQL query.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Please see my reply in your original post of this question: http://www.dbforums.com/oracle/16982...statement.html

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •