PIVOT IN SQL | Advanced SQL | Ashutosh Kumar
Вставка
- Опубліковано 24 жов 2022
- Sql one of the most important language asked in most of the analytics interviews,in this series i have discussed some advanced level sql concepts that are frequently asked in data analyst,business analyst interviews. In this video i have covered non equi joins concepts in sql
👉Query -
drop table if exists customer;
CREATE TABLE customer(cust_id integer,cust_first_name text,cust_last_name text);
INSERT INTO customer(cust_id,cust_first_name,cust_last_name)
VALUES (1,'Henry','Brown'),
(2,'James','Williams'),
(3,'Jack','Taylor');
drop table if exists orders;
CREATE TABLE orders(order_id integer,date date,cust_id integer,amount integer);
INSERT INTO orders(order_id,date,cust_id,amount)
VALUES
(1,'05-08-2020',1,4922),
(2,'04-08-2020',2,7116),
(3,'03-08-2020',3,1206),
(4,'04-08-2020',1,2841),
(5,'05-08-2020',2,2522),
(6,'05-08-2021',3,5084),
(7,'04-08-2021',1,6680),
(8,'03-08-2021',2,8123),
(9,'04-08-2021',3,6015),
(10,'05-08-2021',2,4092),
(11,'05-08-2022',1,7224),
(12,'04-08-2022',2,7679),
(13,'03-08-2022',3,1303),
(14,'04-08-2022',1,5185),
(15,'05-08-2022',2,2139);
select * from orders;
select * from customer;
👉 Complete playlist on Sql Interview questions and answers
• HackerRank SQL problem...
---------------------------------------------------------------------------------------------------------------------
Check out some more relevant content here
👉 How to Learn SQL
• How to learn sql for b...
👉 How to become a business analyst complete roadmap-
• Business Analyst Compl...
👉 How to become a data analyst complete roadmap-
• Data Analyst Complete ...
👉 Top 3 you tube channels to learn sql for free for beginners
• Video
👉 Rank ,Dense Rank, Row Number in sql -
• RANK - DENSE RANK - RO...
👉 Cross join in sql
• CROSS JOIN SQL
👉 union join in sql
• UNION IN SQL
👉 left join in sql
• LEFT JOIN IN SQL
👉 Right join in sql
• RIGHT JOIN IN SQL
👉 Inner join in sql
• INNER JOIN IN SQL
👉 Introduction to tables and databases in sql -
• INTRO TO TABLES AND DA...
👉 Aggregate Function in sql
• AGGREGATE FUNCTION IN SQL
👉 Functions in sql-
• IMPORTANT FUNCTIONS IN...
👉 String Function in sql
• STRING FUNCTIONS IN SQL
👉 CRUD operations in sql
• CREATE- READ- UPDATE-D...
👉 Autoincrement in sql
• Auto Increment in SQL ...
👉 Primary Key in sql-
• PRIMARY KEYS IN SQL - SQL
👉 Null and Default values in sql-
• NULL AND DEFAULT VALUE...
👉 Data types in sql-
• Data types in Sql - SQL
____________________________________________________________________
Fill the form below to subscribe yourself to the analytics jobs mailing list to receive regular job opening updates - docs.google.com/forms/d/e/1FA...
Why you should definitely fill the analytics job updates google form - • Job Openings into busi...
_______________________________________________________________________
Connect with me
📸Instagram - / ashutosh.analytics
💻Linkedin- / ashutoszh
_____________________________________________________________________
Comment down if you have any doubts
Please leave a LIKE 👍 and SUBSCRIBE ❤️ to my channel to receive more amazing content in data analytics and data science.
_____________________________________________________________________
🏷️ Tags
sql,
sql for data science,
sql for data analytics,
sql practise questions,
sql practise questions and solutions,
sql tutorials for beginners,
sql problems for data engineers,
ashutosh,
ashutosh kumar,
ashutosh kumar analytics,
sql problems easy,
sql problem medium,
sql problems hard,
sql window functions,
sql advanced questions,
rank functions in sql,
lag lead in sql,
sql interview questions and answers,
sql interview questions,
sql questions asked in interviews,
hackerrank sql solutions,
hackerearth sql solutions,
leetcode sql solution
🏷️HashTags
#sql #interviews #questions #solutions
Hi Bro I am learning a lot from your videos. The cross-join use case was fabulous. And joining two tables that do not have identical columns. Thank you for making videos in-depth and making us understand how to think while solving a problem in SQL. Waiting for more videos.
Thank you once again.
Thank you
wonderful explanation. Keep it up...
how are you getting the dictinct full names in this problem bro.pleas help me
Instead of giving values in array while doing is there any way we give the column from the table we're looking for ?
thank you for your wonderful explaining Ashutosh👏
this was specififcally for pivot , there are many ways to solve a problem
Hi i have a table with columns like ACC_no,Reim type,total_charges,total_balance,discharge_date.Now i need a pivot with Rows-Reim type, values- count(acc)no), max(date),avg(total_charges),sum(tot_balance) .pls can you help in pivot with mentioned details .. i checked every youtuber explaining the same way with only 3 columns thats is very easy...one in values ,one in rows and one in column that is pretty simple one. can you please help me with my requirement.
sir pls make video how to create function ...
sure
pivot table does'nt work in MYSQL?
Please also attache excel so that we can also practice with you
Hi Rahul you can find the code attached in the description box of the video it's just the same excel sheet data ,all my videos code or files you will find the desc box
Hi Bro, The same result can be obtained by using Joins and Group By clause then why this Pivot?
SELECT A.cust_id, COUNT(B.order_id) AS total_orders FROM Customers AS A JOIN Orders as B ON A.cust_id = B.order_id GROUP BY A.cust_id;
Yes you can solve a problem multiple ways