SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    table record intervals

    I have the following scenario

    table
    amount | letter
    1 | a
    5 | b
    7 | c

    I need a query if
    amount=1,2,3,4,5 it displays letter a
    amount=6,7 it displays letter b
    amount=8,9,... it displays letter c

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select letter  
      from daTable
     where amount
         = ( select max(amount)
               from daTable
              where amount < n )
    where n is the number you're looking up
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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