Results 1 to 3 of 3

Thread: Sql Query

  1. #1
    Join Date
    Jan 2004
    Posts
    20

    Unanswered: Sql Query

    Hi All,
    I have a table say "Random" which has a single column say "X" .This table contains randomly generated numbers between 0-100.Let us this table contains the following numbers 0,10,12,25,99
    I need a sql query which will display the results in the manner specified in the attachment.

    I mean for each value found from table it will be displayed under its appropriate Number Range (i.e a value 72 from the table will be displayed as 1 under the number range 61-100 )

    Thanks in Advance
    Attached Files Attached Files
    Last edited by satya_x; 04-28-04 at 05:36.
    Regards
    Satya

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Code:
    SQL> select x
      2  ,      case when x between 0 and 10 then 1 else 0 end as v_0_10
      3  ,      case when x between 11 and 30 then 1 else 0 end as v_11_30
      4  ,      case when x between 31 and 60 then 1 else 0 end as v_31_60
      5  ,      case when x between 61 and 100 then 1 else 0 end as v_61_100
      6  from   random;
    
             X     V_0_10    V_11_30    V_31_60   V_61_100
    ---------- ---------- ---------- ---------- ----------
             0          1          0          0          0
            10          1          0          0          0
            12          0          1          0          0
            25          0          1          0          0
            99          0          0          0          1

  3. #3
    Join Date
    Jan 2004
    Posts
    20
    Thanks Tony..
    Regards
    Satya

Posting Permissions

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