Results 1 to 5 of 5

Thread: Range

  1. #1
    Join Date
    Apr 2010
    Posts
    30

    Unanswered: Range

    Hi,
    I have a range of values in a column in this format

    0-4
    4-8
    8-12
    12-16
    16-20
    20-24
    24-28
    28-32
    32-36
    36-40
    40-44
    44-48
    48-52
    52-56
    56-60
    60-64
    64-68
    68-72
    72-76
    76-80
    80-84
    84-88
    88-92
    92-96
    96-100

    Now how do I retreive and maintain data in the same sequence?

    When I run a select * query the data is retreived as

    0-4
    12-16
    16-20
    20-24
    24-28
    28-32
    32-36
    36-40
    4-8
    40-44
    44-48
    48-52
    52-56
    56-60
    60-64
    64-68
    68-72
    72-76
    76-80
    8-12
    80-84
    84-88
    88-92
    92-96
    96-100

    So as we see the sequence is different I want the data to be retreived in the first format shown.Kindly help me with a query or procedure to do the same.

    Thanks in advance

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by narayanyr View Post
    I have a range of values in a column in this format
    there's your problem right there

    use two integer columns -- range_from and range_to
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    or if you must insist on your current design, make certtian you write the values either zero or space padded. so if you thinkt hre number range is going to be say 1..999, then at the very least store 1 or two orders of magnitude so for upto 999 I'd suggest store as 00999.

    but thats a kludge worksaround bad design, do as r937 says and dtore the two values as discrete numbers
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Apr 2010
    Posts
    30
    Correct.....I am trying to incorporate the values in a bar chart as x axis.So all values in the column that I refer to in the previous mail would be the values in x-axis.In this case I may not be able to prefix a zero to a value say "04-08".Is there any other way out of this problem?

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    why do you think 'you may not be able to prefix a zero', have you tried?

    what generates the ranges?

    fix the problem there, or fix it at source, fixing at a later stage is a PIA, is fraught with problems and means you need to apply the same fix elsewhere whne you need to use the same data subset.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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