Тёмный
No video :(

SQL Query - Convert data from Rows to Columns | Pivot 

Learn at Knowstar
Подписаться 44 тыс.
Просмотров 186 тыс.
50% 1

This video is part of the series on scenario based SQL Query interview questions.
This discusses how to use a SQL Query to convert data from rows to columns using the SQL - PIVOT function.
Below is the Part 1 of this video which discusses how to use the CASE statement to achieve the same objective.
• SQL Query - Convert da...
SQL Query to dynamically pivot the rows into columns | Dynamic Pivot
• SQL Query | How to dyn...
Must Do Data Analytics Certifications -
Google Data Analytics Professional Certificate
imp.i384100.ne...
Google Advanced Data Analytics Professional Certificate
imp.i384100.ne...
Practice SQL Queries on Your Browser through Interactive Courses -
learnsql.com/?...
Please do not forget to like, subscribe and share.
For enrolling and enquiries, please contact us at
Website - knowstar.org/
Instagram - / learn.knowstar
Blog - know-star.blogs...
Facebook - / knowstartrainings
Linkedin - www.linkedin.c...
Email - learn@knowstar.org

Опубликовано:

 

20 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 57   
@LearnatKnowstar
@LearnatKnowstar Год назад
Register at the below link to get US $100 off for Coursera Plus membership between Sep 8 - Sep 29, 2022. The Coursera Plus membership gets you access to unlimited courses and unlimited certifications! imp.i384100.net/Ke51on
@hmukai001
@hmukai001 3 года назад
Went over many googled articles and they were filled with jargons and did not make any sense to me. After all that, I came across your clip and its solved all the mystery. Thanks for making it so simple to understand!
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you for your kind words.
@LearnatKnowstar
@LearnatKnowstar 2 года назад
You can avoid hardcoding the pivot column names by using dynamic pivot. Here is the video tutorial link ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Abn3w0EYOf4.html
@LearnatKnowstar
@LearnatKnowstar 4 года назад
We have received your SQL Queries asked in interviews and plan videos soon answering those. If you wish to share some more, put them down in the comments below or send us an email! Happy Learning with Learn At Knowstar!
@jacksparrowcapitan3232
@jacksparrowcapitan3232 3 года назад
Your voice is attractive day by day Teacher !!! Great content as always
@kristyowens2284
@kristyowens2284 4 года назад
Learned a new SQL function today - interesting. Thanks.
@LearnatKnowstar
@LearnatKnowstar 4 года назад
Thank you
@sherrimcdonald2382
@sherrimcdonald2382 3 года назад
Thank you for this. I learned about a much needed function in order for me to build a ssrs report.
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you. Glad that you found this useful.
@RamPrasad-io2kz
@RamPrasad-io2kz 2 года назад
Thank you ma'am it is very helpful this pivot function for my automations
@LearnatKnowstar
@LearnatKnowstar 2 года назад
Thank you. Glad that it was useful.
@bw424
@bw424 3 года назад
It's not ideal that you have to know the values to use as pivot table columns. What if you wanted to base it off a sequential order? Like have the top value as the first column, the second value as the second column, etc. That way you could grab the top results and pivot them in order. I think this would be pretty easy to do in pandas.
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Sure pandas are very effective
@AndrewJens
@AndrewJens Год назад
The only way to have a variable number of output columns (from a PIVOT query) is to preconstruct the desired SELECT column names in a string variable and then use it to construct the entire PIVOT query as a string variable, which you can then run via the execute() command (i.e. use dynamic SQL). To construct the SELECT column names, look to use something like: set @cols = (select string_agg(quotename(), ',') from (select...) as t)
@MaxyX
@MaxyX 3 года назад
You a genius
@junevutran3986
@junevutran3986 3 года назад
Thank you so much. This is what I am looking for
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thanks so much!
@sindhuratridandapani9750
@sindhuratridandapani9750 3 года назад
Hi . This video is informative. However, I am looking for a pivot function when there are all String columns . What aggregate function can we use for String column?
@anudharsanbaskar3284
@anudharsanbaskar3284 Год назад
@sindhuja tridandapani hii
@AndrewJens
@AndrewJens Год назад
She gives the answer in the video: the max() function.
@milloons2847
@milloons2847 2 года назад
Thanks, clear and concise tutorial.
@LearnatKnowstar
@LearnatKnowstar 2 года назад
Thank you
@hulkbaiyo8512
@hulkbaiyo8512 2 года назад
okay, tbh I think first method is easy to understand and use. but probably second one is common use. I just don''t like that pivot format
@shirishshukla9833
@shirishshukla9833 3 года назад
What does max function do here? Why was the aggregate needed?
@pradeepkumar-xt5dy
@pradeepkumar-xt5dy 3 года назад
It's very useful
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you
@CiprianZahariaRO
@CiprianZahariaRO 3 года назад
Nice explanation
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you
@sweetysweetyvghb
@sweetysweetyvghb 3 года назад
Mam..Pls explain how to write the Pivot query if multiple records are present ...do we need to use partitions in the query ?
@babun4915
@babun4915 Год назад
Hi great work ...!! Can we have a entire course like video in converting the queries or stored procedures from oracle to ms sql
@karthikj9326
@karthikj9326 Год назад
hello mam, this is very helpful, however, was wondering if you have any video anywhere of yours on multiple pivot
@dimpyrathore818
@dimpyrathore818 4 года назад
Wow. Didn't know about this function.
@LearnatKnowstar
@LearnatKnowstar 4 года назад
Thank you
@operationbroomstick
@operationbroomstick Год назад
Thank you ☺️
@LearnatKnowstar
@LearnatKnowstar Год назад
Glad it was helpful.
@ThePHnunes
@ThePHnunes 2 года назад
How can i do that, when i want to show more than one row in that case? Example: I have a city name (collumn name) and in the rows i will put the name of the places. If i put MAX on the pivot, they show me only 1 row, but i need that they show me all the places... i need use another function, or pivot can attend me?
@DeoFederickDuran223
@DeoFederickDuran223 3 года назад
THIS JUST SAVE ME!! wew
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you
@ruchiagrawal3029
@ruchiagrawal3029 Год назад
How to do this for both , and blank separator
@houstonfirefox
@houstonfirefox Год назад
Good video. Going forward and when producing education content, please refrain from using reserved words such as "Name" and "Value" in your SQL code. It makes me cringe when I see developers use reserved words as column names.
@LearnatKnowstar
@LearnatKnowstar Год назад
Thank you. Will keep this in mind 👍
@nimmanigga4473
@nimmanigga4473 3 года назад
Select * from dbo.Emp Select ID,[Name],[Gender],[salary] from (Select ID,Name as EName, Value From dbo.Emp) as Source_Table PIVOT (Max(Value) For EName in ([Name], [Gender], [Salary]) ) as Pivot_Table
@arunv1909
@arunv1909 2 года назад
does this wroks in sql workbench ?i guess pivot dont work in tat
@akhandbharat2463
@akhandbharat2463 3 года назад
But keep up the good work
@widzewisze8475
@widzewisze8475 3 года назад
hi ! nice video thanks alot ;but what about N rows ? i mean in rows >3 ?
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you. You can use the same logic and extend the SQL for more than 3 rows as well. You need to mention the additional rows as pivot columns and values.
@haederoth
@haederoth 2 года назад
Hello. If someone can help --> What code lines need to be added in order to copy the result of this query into an other table of the database ? Many thanks !!!!
@houstonfirefox
@houstonfirefox Год назад
Use the SELECT * INTO newtablename FROM (subquery) alias (subquery) would refer to the entirety of the SQL as shown in the video. "alias" can be any word you'd like to refer to the subquery as.
@gashok5231
@gashok5231 Год назад
How to pivot a row word 'oracle'as column can anyone write syntax
@miguelcastillo7346
@miguelcastillo7346 3 года назад
Izi pizi to understand
@LearnatKnowstar
@LearnatKnowstar 3 года назад
Thank you
@RameshK-rn3hf
@RameshK-rn3hf 3 года назад
Please improve the Video quality, otherwise it is very good
@akhandbharat2463
@akhandbharat2463 3 года назад
Need to work on the way you explain. It’s difficult to understand
@srirammaddula5661
@srirammaddula5661 Год назад
Yes.
@joesyereadi9078
@joesyereadi9078 3 года назад
Please help me, what if i have 2 tables.. the first table contains: id, name, age, the second tables contains : idage16, idage17,idage18 like this: table 1 people table 2 age ---------------------------- ------------------------------------------------- id name age ideage16 ideage17 ideage18 ---------------------------------------------------------- -------------------------------------------------------------------- 1 joe idage16 90 80 70 the question is how can i get value in the third table like this id name age point ------------------------------------------------------------------- 1 joe idage16 90 pliss help me for make videos...
Далее
skibidi toilet zombie universe 40 ( New Virus)
03:06
Просмотров 842 тыс.
PIVOT IN SQL | Advanced SQL | Ashutosh Kumar
18:37
Просмотров 8 тыс.
Pivoting Data with SQL
9:33
Просмотров 11 тыс.
Dynamically Pivot Data in SQL Server
13:50
Просмотров 83 тыс.