No video

SQL Query | How to dynamically convert rows into columns | Dynamic Pivot

  Рет қаралды 57,170

Learn at Knowstar

Learn at Knowstar

Күн бұрын

Пікірлер: 89
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
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
@sylvia3820
@sylvia3820 2 жыл бұрын
Outstanding!! Was in a hurdle and thanks to you I was able to finish my report at work . Thank you so much for your teaching ❤️
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad it was helpful 🙏
@rajkotipatelgunishetti8813
@rajkotipatelgunishetti8813 6 ай бұрын
Outstanding ,it was clear as expected
@LearnatKnowstar
@LearnatKnowstar 6 ай бұрын
Glad it was helpful.
@kamskamundu6720
@kamskamundu6720 2 жыл бұрын
Thanks very much. Then m'y question IS that how to join this pivot function with and other query in order to get opennning balance in report.
@Shashankgupta004
@Shashankgupta004 Ай бұрын
@LearnatKnowstar Thanks for sharing such an amazing method of pivoting rows into columns but i have a question here , what if we want to execute similar operation with columns to rows then how it would be possible as columns name are not stored anywhere which can be called in pivot function. Please advise.
@sholland42
@sholland42 2 жыл бұрын
Nice presentation. Try hitting ctrl-shift-r to refresh the intellisense cache and the red squigglies go away.
@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 !!!!
@vishalransing9531
@vishalransing9531 10 ай бұрын
Superb explanation
@LearnatKnowstar
@LearnatKnowstar 10 ай бұрын
Thank you 🙂
@navyavs7902
@navyavs7902 2 жыл бұрын
How to do this in sql oracle 12g?
@persianimmortal7642
@persianimmortal7642 3 жыл бұрын
You explain sql query very meaningful
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@SandeepTiwari-yy4fg
@SandeepTiwari-yy4fg Жыл бұрын
how to make zero(0) if salary is null or how to use ISNULL function here
@vidyak8638
@vidyak8638 5 ай бұрын
Can you please explain same query for Oracle sql
@hv0032113
@hv0032113 3 жыл бұрын
You make it so easy to understand. Thank you.
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@Anaya-un4ge
@Anaya-un4ge 2 жыл бұрын
This is really good!! Thankyou for making it so easy to understand. I have a question. What if the Emp table is continuously getting new data every 15 mints. Would it be possible to do this without doing it from scratch everytime?
@shailendrakushwaha2130
@shailendrakushwaha2130 2 жыл бұрын
error while using string_agg function in sql server 2012: 'STRING_AGG' is not recognized built-in function name. pls help
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
You need to try alternate approach. SET @cols = STUFF((SELECT distinct ',' + QUOTENAME(c.Name) FROM dbo.Empl1 c FOR XML PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)') ,1,1,'') To understand how this works, you can check the below video tutorial - kzbin.info/www/bejne/l3WrZYtoo81sY5o
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
You can also check out this forum - stackoverflow.com/questions/10404348/sql-server-dynamic-pivot-query
@nimeshkotadia6526
@nimeshkotadia6526 Жыл бұрын
Above method breaks down when i already have where condition with dates or names which already uses ' ' to convert to string. Any help around this would be helpful. Dynamic pivoting with where condition in the base query.
@petermaina7111
@petermaina7111 Жыл бұрын
You are a practically great
@LearnatKnowstar
@LearnatKnowstar 11 ай бұрын
Hope this was helpful.
@alwayschandra
@alwayschandra 3 жыл бұрын
Nice explanation and very easy to implement . Thank You
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad you liked it
@haederoth
@haederoth Жыл бұрын
UP. 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 !!!!
@francois7491
@francois7491 10 ай бұрын
Brilliant. Very helpful, thank you so much!
@LearnatKnowstar
@LearnatKnowstar 10 ай бұрын
Glad it was helpful!
@miasp786
@miasp786 Жыл бұрын
How to sort the column using this query
@scvrive
@scvrive 2 жыл бұрын
thank you that was great , i want to combine fields from 2 more tables , lets say name was an ID to employee table andin the employee table there is a Dept ID linking to the department table , do you have another example i can watch to develop a multi table example
@StefanoVerugi
@StefanoVerugi 2 жыл бұрын
excellent explanation, many thanks
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you so much
@johnghirardi
@johnghirardi Жыл бұрын
This was really useful and easy to follow. Thank you so much for sharing your knowledge! :)
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful
@tnmyk_
@tnmyk_ Жыл бұрын
Amazing explanation! Thank you very much!
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful!
@aswinkumar9751
@aswinkumar9751 3 жыл бұрын
Great work madam.i really appreciate it ☺️☺️
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@satyamsinha5429
@satyamsinha5429 Жыл бұрын
I have 1 question for pivoting
@PrakashPraaku
@PrakashPraaku 7 ай бұрын
AMAZINGGGGG!! 👌👌👏👏
@LearnatKnowstar
@LearnatKnowstar 7 ай бұрын
Thanks!!
@nimeshkotadia6526
@nimeshkotadia6526 Жыл бұрын
how to execute the @sql into a temporary table? Basically, I am trying add a column for Total.
@saket2006
@saket2006 Жыл бұрын
This is extremely helpful - thank you for sharing.
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful.
@hesam46
@hesam46 Жыл бұрын
Thank you for this great video. How can I get the Demo database to replicate what you do?
@saisubramanian6908
@saisubramanian6908 Жыл бұрын
excellent article and helped to move forward
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thank you
@zeeshanazeem5212
@zeeshanazeem5212 Жыл бұрын
Excellent Work. works like a charm,
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful.
@sourabhpatil2361
@sourabhpatil2361 2 жыл бұрын
Mam one Question I we want one particular name at top and other remaining names down the top name then what is query for that?
@bhargavigogulamudi2758
@bhargavigogulamudi2758 Жыл бұрын
Can you please explain how to convert rows into columns dynamically in postgresql?
@kartik-wi2jv
@kartik-wi2jv 3 жыл бұрын
Mam.. your personal audio added in between.. plz take care..
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you for pointing it out. Reedited the video. Thank you.
@kartik-wi2jv
@kartik-wi2jv 3 жыл бұрын
@@LearnatKnowstar thank you so much mam for sharing your knowledge..
@aneelt919
@aneelt919 3 ай бұрын
Awesome.
@LearnatKnowstar
@LearnatKnowstar 2 ай бұрын
Thank you
@surik972
@surik972 2 жыл бұрын
Thanks a lot madam for all ur efforts!! Do u have any plans to start the oracle plsql concepts
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad it was helpful. We are definitely planning it in the future. Stay tuned and Subscribe 🙂
@sunilshinde9897
@sunilshinde9897 Жыл бұрын
Awesome.Thank you mam.its great Tut.
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thank you
@leolitvinsky4139
@leolitvinsky4139 2 жыл бұрын
order by is not allowed in subquery.
@gregorybuiche5084
@gregorybuiche5084 2 жыл бұрын
Gregory Buiche Nice explanation. Is there a way to make the same job without STRING_AGG for users of SQL SERVER 2014 😢
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you. You can try using 'for xml' and stuff. It is explained in the below video - kzbin.info/www/bejne/l3WrZYtoo81sY5o
@shaiprabudhanasekaran7880
@shaiprabudhanasekaran7880 2 жыл бұрын
Ma'am How to remove the space in between each Column Names.
@sanjaysunilkumar3674
@sanjaysunilkumar3674 2 жыл бұрын
very good tutorial
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you!
@ismaelobligacion7531
@ismaelobligacion7531 Жыл бұрын
Please comment here your whole query..,thank you,,
@melissawareham7429
@melissawareham7429 2 жыл бұрын
fabulous, very helpful, thank you!!
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you so much!
@ninhduongchan763
@ninhduongchan763 2 жыл бұрын
which is the type of ''value''?
@ninhduongchan763
@ninhduongchan763 2 жыл бұрын
What is the 'value'?
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Value is a column name in the original table.
@terryh558
@terryh558 2 жыл бұрын
Awesome!😊
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you 🙏
@jeromevanbeek9070
@jeromevanbeek9070 2 жыл бұрын
How do you do this with MySQL?
@tusharjadhav6940
@tusharjadhav6940 2 жыл бұрын
Hello mam , i have one string (my|name|is|tushar|abc|ahha|haha|hshs) I already separated it using create function which is similar like string_split because i have old version of server, So sir , i have table which contains 8 columns col1,col2,col,3 I have to insert the seprated string values into this columns(8 columns are their) I am seprated it but they are form rows My Name Is Tushar Like that i need to insert into columns or horizontal way. And its completely dynamic Can you help me out???
@ninhduongchan763
@ninhduongchan763 2 жыл бұрын
why is the "value" blue?
@sholland42
@sholland42 2 жыл бұрын
It’s a SQL keyword
@capitalInd
@capitalInd 3 жыл бұрын
Declare @HOD Nvarchar(max); Declare @Sql Nvarchar(max); set @HOD= (select STRING_AGG([HOD Name],',') from (select distinct [HOD Name] from Dealer)a); Set @Sql = 'select' + @hod + 'from (Select [HOD Name] from Dealer) as Src_Table Pivot (count([HOD Name]) for [HOD Name] in ( ' + @HOD + ' )) as pvt' execute (@sql) AFTER EXECUTE SHOW ERROR = Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ','. Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'as'. PLEASE HELP
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
You can try printing @sql text and check for any syntax errors. It could be due to missing spaces around the @col values that you have inserted.
@capitalInd
@capitalInd 2 жыл бұрын
@@LearnatKnowstar printing @sql text working fine but giving error while executing @sql check printing @sql text select Aashish .,Ajit Kumar Singh,Anup Kumar Chaudhary,Ashutosh Goutam,Bhavesh R Kanadiya,Brijender Kumar,Deepak Chaudhary,Gautam Singh,Juned Niyaj Ahmad,Madhu . Kashyap,Mayur Tarachand Purohit,Mohammad Khalid,Mohd Danish Shaikh,Mukesh Kumar Ray,Pankaj Kumar Singh,Piyusha Satish Kotkar,Ritesh Kumar Sinha,Sani Kumar Kanojia,Suman Kumar,Tahseen Raza Khan,Tribhuwan Narayan Pandey,Varun Ashok Sharma,Vivek Kushwahafrom (Select [HOD Name] from Dealer) as Src_Table Pivot (count([HOD Name]) for [HOD Name] in ( Aashish .,Ajit Kumar Singh,Anup Kumar Chaudhary,Ashutosh Goutam,Bhavesh R Kanadiya,Brijender Kumar,Deepak Chaudhary,Gautam Singh,Juned Niyaj Ahmad,Madhu . Kashyap,Mayur Tarachand Purohit,Mohammad Khalid,Mohd Danish Shaikh,Mukesh Kumar Ray,Pankaj Kumar Singh,Piyusha Satish Kotkar,Ritesh Kumar Sinha,Sani Kumar Kanojia,Suman Kumar,Tahseen Raza Khan,Tribhuwan Narayan Pandey,Varun Ashok Sharma,Vivek Kushwaha )) as pvt PLZ HELP HOW TO RESOLE THIS ERROR
@TheRaju991
@TheRaju991 2 жыл бұрын
@@capitalInd I know it's been a very long time. But there was a typo at this line with two closing parenthesis )) Pivot (count([HOD Name]) for [HOD Name] in ( ' + @HOD + ' )) as pvt' so fix should have been only: Pivot (count([HOD Name]) for [HOD Name] in ( ' + @HOD + ' ) as pvt'
@Hammersteyn
@Hammersteyn Жыл бұрын
what?
@aadarshchaudhari3957
@aadarshchaudhari3957 Жыл бұрын
Nice explanation. thank you so much
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful.
SQL Query | How to identify Overlapping Date Ranges
8:12
Learn at Knowstar
Рет қаралды 22 М.
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 55 МЛН
Solving SQL Query | Rows to Column in SQL
1:13:11
techTFQ
Рет қаралды 169 М.
SQL Query | Convert data from columns into Rows | Unpivot
7:41
Learn at Knowstar
Рет қаралды 62 М.
SQL Query | How to find Maximum of multiple columns | Values
8:00
Learn at Knowstar
Рет қаралды 112 М.
Dynamically Pivot Data in SQL Server
13:50
Anthony Smoak
Рет қаралды 83 М.
SQL Query - Convert data from Rows to Columns |Case | Pivot data
7:14
Learn at Knowstar
Рет қаралды 48 М.