SQL Interview Questions And Answers Part 60 | How to forward fill NULL values with the last Non NULL value
This question has been asked in many company and it will be helpful in cracking any SQL interview
Problem Statement : Stocks Table consists of DateKey, StockName and Price.
Write a SQL query to derive another column MarketPrice where it is going to forward fill NULL values with the last Non NULL value
-------------------------------------------------------------------------
𝗝𝗼𝗶𝗻 𝗺𝗲 𝗼𝗻 𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:🔥
-------------------------------------------------------------------------
*Instagram :
/ itjunction4all
*Twitter:
/ sunilkr5672
-------------------------------------------------------------------------
Table and Insert SQL Script :
-------------------------------------------------------------------------
create table Stocks
(DateKey Date,
StocksName varchar(20),
Price int
);
insert into Stocks values
('20230101','Infosys',1400)
,('20230102','Infosys',null)
,('20230103','Infosys',1450)
,('20230104','Infosys',null)
,('20230105','Infosys',null)
,('20230105','Infosys',null)
,('20230101','Reliance',2300)
,('20230102','Reliance',NULL)
,('20230103','Reliance',null)
,('20230104','Reliance',2375)
,('20230105','Reliance',2400)
,('20230106','Reliance',null)
#WALMARTInterview #FAANG #SQLInterviewQuestionsandanswers #sqlInterviewQuestions #MAANG #sqlInterviewQuestionsForTesting
Watch video SQL Interview Questions And Answers Part 60 | How to fill NULL values with the last Non NULL value online without registration, duration hours minute second in high quality. This video was added by user ItJunction4all 29 January 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5,39 once and liked it 14 people.