Results 1 to 2 of 2

Thread: Range select

  1. #1
    Join Date
    Feb 2004
    Location
    Jordan
    Posts
    137

    Unanswered: Range select

    Hi all

    I have 2 tables T1 like this :

    from_no to_no value
    ---------------------------------------
    0 100 A
    101 200 B
    201 300 C

    and T2 like this :

    name amount
    ----------------------------
    toto 189
    soso 12
    roro 288

    I want a select that return this

    toto B
    soso A
    roro C


    thanx in advance

  2. #2
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    Assuming they are no overlapping from_no to_no
    Code:
    SQL> select t2.name, t1.value
      2    from t2 inner join t1
      3      on t2.amount between t1.from_no and t1.to_no
      4  /
    
    NAME       V
    ---------- -
    roro       C
    toto       B
    soso       A

Posting Permissions

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