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
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!
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.
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)
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?
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.
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
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.
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!
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?
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 !!!!
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.
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...
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
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!
Thank you for your kind words.
Your voice is attractive day by day Teacher !!!
Great content as always
Thank you for this. I learned about a much needed function in order for me to build a ssrs report.
Thank you. Glad that you found this useful.
Learned a new SQL function today - interesting. Thanks.
Thank you
Thank you ma'am it is very helpful this pivot function for my automations
Thank you. Glad that it was useful.
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.
Sure pandas are very effective
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)
Thank you so much. This is what I am looking for
Thanks so much!
Thanks, clear and concise tutorial.
Thank you
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
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?
@sindhuja tridandapani hii
She gives the answer in the video: the max() function.
hello mam, this is very helpful, however, was wondering if you have any video anywhere of yours on multiple pivot
Hi great work ...!!
Can we have a entire course like video in converting the queries or stored procedures from oracle to ms sql
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.
Thank you. Will keep this in mind 👍
You a genius
What does max function do here? Why was the aggregate needed?
Mam..Pls explain how to write the Pivot query if multiple records are present ...do we need to use partitions in the query ?
It's very useful
Thank you
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
You can avoid hardcoding the pivot column names by using dynamic pivot.
Here is the video tutorial link
th-cam.com/video/Abn3w0EYOf4/w-d-xo.html
Nice explanation
Thank you
Wow. Didn't know about this function.
Thank you
hi ! nice video thanks alot ;but what about N rows ? i mean in rows >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.
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!
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?
Thank you ☺️
Glad it was helpful.
How to do this for both , and blank separator
does this wroks in sql workbench ?i guess pivot dont work in tat
THIS JUST SAVE ME!! wew
Thank you
Please improve the Video quality, otherwise it is very good
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 !!!!
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.
How to pivot a row word 'oracle'as column can anyone write syntax
Need to work on the way you explain. It’s difficult to understand
Yes.
But keep up the good work
Izi pizi to understand
Thank you
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...