Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Propagate row data until next date is encountered - response (3) by dnoeth

$
0
0

Hi Harry,
when you're on TD13.10 you can use EXPAND ON:

SELECT name, BEGIN(pd2) AS newdate, amt 
FROM 
 (
   SELECT
      name, datecol, amt, 
      PERIOD(datecol,
             COALESCE(MIN(datecol) 
                      OVER (PARTITION BY name 
                            ORDER BY datecol 
                            ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING), CURRENT_DATE)) AS pd
   FROM tab
 ) AS dt
EXPAND ON pd AS pd2 BY INTERVAL '1' DAY
ORDER BY 1,2

 Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles