Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

window function to forward fill

-- USE LAG IGNORING NULLS AND GRAB PREVIOUS VALUE. FILTER OPPOSITE DIRECTION TO GET BACK FILL
SELECT  
		DATE,
        GROUP,
        REVENUE
        COALESCE(REVENUE, LAG(REVENUE) IGNORE NULLS OVER (PARTITION BY GROUP order by DATE), LAG(REVENUE) IGNORE NULLS OVER (PARTITION BY GROUP order by DATE DESC)) as FILL_VALUE
FROM _ADS A
 
PREVIOUS NEXT
Tagged: #window #function #fill
ADD COMMENT
Topic
Name
3+8 =