Archives of the TeradataForum
Message Posted: Thu, 29 Mar 2007 @ 21:05:13 GMT
You can use the calendar view or similar structure to normalize the values and take the minimum.
However, if your source table has many rows and many columns you may not want to use cross product join method as it could create a massive spool file.
Example for 5 column comparison:
select t.groupingcolumns ,min (case c.day_of_calendar when 1 then col1 when 2 then col2 when 3 then col3 when 4 then col4 else col5 end) as min_col_value from tablename t cross join sys_calendar.calendar c where c.day_of_calendar <=5 group by 1;
|Copyright 2016 - All Rights Reserved|
|Last Modified: 28 Jun 2020|