Welcome to today’s SQL tutorial! In this video, we'll solve an interesting problem that involves finding the Net Present Value (NPV) for queries from two tables using SQL.
Script -
Table: npv
CREATE TABLE npv (
id INT,
year INT,
npv DECIMAL(10, 2)
);
INSERT INTO npv (id, year, npv)
VALUES
(1, 2018, 100),
(7, 2020, 30),
(13, 2019, 40),
(1, 2019, 113),
(2, 2008, 121),
(3, 2009, 12),
(11, 2020, 99),
(7, 2019, 0);
Table - queries
CREATE TABLE queries (
id INT,
year INT
);
INSERT INTO queries (id, year) VALUES
(1, 2019),
(2, 2008),
(3, 2009),
(7, 2018),
(7, 2019),
(7, 2020),
(13, 2019);
TIMESTAMP
00:00 Introduction
00:14 Problem Explanation
02:28 Solution Approach
03:40 MySQL Solution Implementation
https://www.youtube.com/watch?v=gKSs5yIvTgs&list=PLU8R7xIwX9dBmUEBq-rwUSE6n60K6nYrs
#sql #sqlinterview #dataanalysts #dataengineer #dataanalysis #interviewquestion