SQL Interview Questions & Answers | Part-3

Опубликовано: 30 Июль 2024
на канале: Sagar's Data Journey
539
7

This is the third video of our series on SQL interview questions and answers. This series is specifically designed for people targeting jobs as data analysts, data scientists, data engineers, business analysts and Software Engineer. Also this video is helpful for those students who are studying in Computer Science Engineering and AI and DSA.

In this video, I have explained Answer for
Problem Statement:-
Write a SQL code to get the total number of new customers who did a successful transaction in the month of June 2021.

Use below script to create the Tables:-
Create Customer
CREATE TABLE Customer (
CustomerID VARCHAR(3) primary key,
CustomerSegment VARCHAR(10),
CustomerCity VARCHAR(20)
);

Create Merchants
CREATE TABLE Merchants (
MerchantID VARCHAR(2) primary key,
MerchantName VARCHAR(20)
);

Create Transactions
CREATE TABLE Transactions (
TransactionID INT,
OrderDate DATE,
CustomerID VARCHAR(3),
MerchantID VARCHAR(2),
TransactionAmount INT,
TransactionStatus VARCHAR(10),
foreign key(CustomerID) references Customer(CustomerID),
foreign key(MerchantID) references Merchants(MerchantID)
);

-- Insert data into Customer
INSERT INTO Customer VALUES
('C1', 'New', 'Delhi'),
('C2', 'New', 'Kolkata'),
('C3', 'Repeat', 'Mumbai');

-- Insert data into Merchants
INSERT INTO Merchants VALUES
('M1', 'Airtel'),
('M2', 'Jio');

-- Insert data into Transactions
INSERT INTO Transactions VALUES
(1234, '2021-06-02','C1' , 'M1', 450, 'Success'),
(2134, '2021-06-07','C2' , 'M1', 450, 'Success'),
(1234, '2021-06-014','C1' , 'M2', 320, 'Fail');

Join My Telegram Channel to download the notes👇:
Telegram : https://t.me/+SphVEMyx2m02NWJl

⚠️Don't Forget to Subscribe My Channel !

Follow me on👇
Instagram :   / sagar.dodamani  
LinkedIn :   / sagardodamani  
GitHub : https://github.com/Dodamanisagar
Telegram : https://t.me/+SphVEMyx2m02NWJl


Смотрите видео SQL Interview Questions & Answers | Part-3 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Sagar's Data Journey 30 Июль 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 539 раз и оно понравилось 7 людям.