| Archives of the TeradataForumMessage Posted: Fri, 08 Feb 2008 @ 16:45:47 GMT
 
 
  
| Subj: |  | Re: How to code a join or restructure table? |  |  |  | From: |  | Curley, David |  
 What if they decide to add a step between some of the current amounts?  You'd have to generate a new ID for every row.  (A good example of why
a surrogate key should have no meaning other than as a key.) If all you want is the row with the greatest amount less than or equal to X, something like these should work: 
     Select top 1 *
      from adhoc.rates
     Where amount <= .1653
     Order by amount desc
 Or 
     Select *
      from adhoc.rates
     Where amount <= .1653
     Qualify row_number() over (order by amount desc) = 1
 Dave 
 
 |