  |  
  |  
 
Archives of the TeradataForum 
 
 
Message Posted: Thu, 18 Oct 2007 @ 12:27:24 GMT 
 
  
 
 
 
 
  
|  Subj:  |   |  Re: Conditionally Converting a Many to One relationship  |   
|     |   
|  From:  |   |  Michael Larkins  |   
  
 
 
  
Hi Mat: 
This is really quite an easy task when you use a case with a derived table: 
     select item
             ,case when mn=1 and mx=1 then 5
                   when mn=2 and mx=3 then 4
                                      else 6
     from (select item_id item, min(item_attribute) mn, max(item_attribute) mx
            from item_table
            group by item_id) min_max
 Hope this helps, 
Michael Larkins 
Certified Teradata Master 
Certified Teradata SQL Instructor 
 
 
 
 
   
 
 |   |