Consider a table with two columns. The first, ID, is an incrementing integer, the primary key of
Fantastic news! We've Found the answer you've been seeking!
Question:
Consider a table with two columns. The first, ID, is an incrementing integer,
the primary key of the table. The second column contains data values. Some
data values may be NULL. Here is the script that creates the temp table with
data values.
-- Create the table
CREATE TABLE #TableValues(ID INT, Data INT);
-- Populate the table
INSERT INTO #TableValues(ID, Data)
VALUES(1,100),(2,100),(3,NULL),
(4,NULL),(5,600),(6,NULL),
(7,500),(8,1000),(9,1300),
(10,1200),(11,NULL);
-- Display the results
SELECT * FROM #TableValues;
The exercise is to use window functions to replace each NULL value with the
previous non-NULL value.
Related Book For
Macroeconomics Principles Applications And Tools
ISBN: 9780134089034
7th Edition
Authors: Arthur O Sullivan, Steven M. Sheffrin, Stephen J. Perez
Posted Date: