Thursday, August 18, 2016

First or Last of a Set


If you need the 1st or last of a set, try this code:


SELECT year_code                                                     AS "Year"
     , MIN(month_title) KEEP (DENSE_RANK FIRST ORDER BY period_code) AS "First"
     , MAX(month_title) KEEP (DENSE_RANK LAST  ORDER BY period_code) AS "Last"
  FROM dlvr_time
 GROUP BY year_code
 ORDER BY year_code;
 

No comments:

Post a Comment