SQL Interview questions & Answers | Part-1

Опубликовано: 18 Август 2024
на канале: Sagar's Data Journey
324
11

This video is the first 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, 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 query to rearrange the Product table so each row has (product_id, store, price). If a product is unavailable in a store, do not include a row with that product_id and store combination in the result table.
Note: Return the result ordered by store in ascending order

I have explained Answer for the above problem statement in 3 different Methods
1) By using UNION and ORDER BY
2) By using UNION , CASE Statement and ORDER BY
3) By using UNION CASE Statement, CROSS JOIN and ORDER BY

Use the below the commands to create your own database and table:
CREATE DATABASE INTERVIEW_DB;

Select Database to store the table:
USE INTERVIEW_DB;

drop table if exist:
drop table if exists product;

Create the 'products' table:
CREATE TABLE product
(
product_id INT PRIMARY KEY,
store1 INT, -- product price in store 1
store2 INT, -- product price in store 2
store3 INT -- product price in store 3
);

Insert data into the 'products' table:
INSERT INTO product
(product_id, store1, store2, store3)
VALUES
(0, 90, 105, 110),
(1, null, 87, 85),
(2, null, 30, 40);

You can download the final script from here👇:
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

#coding
#databasesolutions
#rdbms
#sql
#interviewquestions
#interviewquestionsandanswers
#dataanalyst
#businessanalyst
#softwareengineer
#sqlcourse


Смотрите видео SQL Interview questions & Answers | Part-1 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Sagar's Data Journey 18 Август 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 324 раз и оно понравилось 11 людям.