SQL Interview questions | Data Analyst | Part - 2
Vložit
- čas přidán 4. 07. 2024
- This video is the second part 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, and business analysts.
In this video, I have explained how to use the RANK() OVER PARTITION() function to find the second highest-selling product in each category.
Use the below the commands to create your own database and table:
CREATE DATABASE THEMLMINE;
USE THEMLMINE;
CREATE TABLE sales (
order_id INT PRIMARY KEY,
product_name varchar(20) NOT NULL,
units_sold INT DEFAULT 0,
unit_price FLOAT
);
CREATE TABLE products (
category varchar(20) NOT NULL,
product varchar(20)
);
INSERT INTO sales VALUES
(122,'Bikaji_namkeen',1500,200),
(112,'Lays',10000,20),
(110,'Amul_kool',2200,25),
(138,'Dairy_milk',2000,149),
(202,'Monaco',9000,50),
(118,'Coke',7000,95),
(104,'Appy_fizz',8000,35),
(189,'KitKat',4500,70),
(238,'Dosa_batter',3000,99),
(199,'Munch',4500,80),
(448,'Maggi',10000,168);
INSERT INTO products VALUES
('Snacks','Bikaji_namkeen'),
('Snacks','Lays'),
('Snacks','Monaco'),
('Drinks','Amul_kool'),
('Drinks','Coke'),
('Drinks','Appy_fizz'),
('Chocolates','KitKat'),
('Chocolates','Munch'),
('Chocolates','Dairy_milk'),
('Instant_food','Dosa_batter'),
('Instant_food','Maggi');
You can download the final script from here: drive.google.com/file/d/1diLH...
Learn SQL from scratch: • SQL Tutorial for begin...
Instagram: / the_ml_mine
Timestamps:
00:00 Introduction
00:05 Interview question
03:20 MySQL workbench
04:53 Writing SQL query
09:48 Using subquery method
11:50 Using CTE method
12:37 Outro
Music credits:
Intro music - Education - upbeat positive (short ver.) by AudioCoffee -- freesound.org/s/724628/
-- License: Attribution NonCommercial 4.0
Perfectly 👌✅✅
Keep making such sql interview question videos. Pls
Sure, I already have part - 3 and part - 4 as well in this series. If you have any specific category of question that you want me to cover which is often asked in any interview, then let me know. I will make a separate video on that :)
its very helpful brother, but one more suggestion please also include more scenario in same case.
Thanks for the feedback. Point noted
Well explained 👌👌.. Helpful
Thanks subha
Brother make a video on TCS SQL interview questions for freshers 😊. I learned SQL in 4 days. But I should prepare interview questions 😅. I have interview on 5th July. And give me tips as I am a fresher 😊.
Hello Mathew, good luck with your interview. However, I am sorry as I will not be able to make the video in this short period. But I have some tips for you -
Tips: You can watch videos on TCS interview recordings conducted by TCS team itself (Link: czcams.com/video/yqqnKfms3Pg/video.html). Prepare both theory and practice questions. For theory you can refer to this video: czcams.com/video/OLusO6Wdkqw/video.htmlsi=DcaIwO4PmWa0iJHy
Hope you get through the interview.
P.S. Never pretend if you don't know the answer, interviewers are smart enough to catch that. Be confident.
And if you like, you can post your interview questions here and I will try to make a separate video on those. Thanks