Pivoting Data with SQL
Вставка
- Опубліковано 26 лип 2024
- Let's demystify the art of pivoting data with SQL. Learn how to transform your dataset into a more organized and insightful format with just a few SQL queries. Whether you're a beginner or an experienced SQL user, this tutorial will help you pivot your data like a pro. Don't miss out on this essential skill for data manipulation!
👍 If you enjoy this video and are interested in formal training on Power BI, Power Apps, Azure, or other Microsoft products you can use my code "Austin30" at check out when purchasing our On-Demand Learning classes to get an extra 30% off - pragmaticworks.com/pricing/
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - -
Next step on your journey:
👉 On-Demand Learning - Start With The FREE Community Plan: tinyurl.com/2ujujsb5
🔗Pragmatic Works On-Demand Learning Packages: pragmaticworks.com/pricing/
🔗Pragmatic Works Boot Camps: pragmaticworks.com/boot-camps/
🔗Pragmatic Works Hackathons: pragmaticworks.com/private-tr...
🔗Pragmatic Works Virtual Mentoring: pragmaticworks.com/virtual-me...
🔗Pragmatic Works Enterprise Private Training: pragmaticworks.com/private-tr...
🔗Pragmatic Works Blog: blog.pragmaticworks.com/
Let's connect:
✔️Twitter: / pragmaticworks
✔️Facebook: / pragmaticworks
✔️Instagram: / pragmatic.works
✔️LinkedIn: / pragmaticworks
✔️UA-cam: / pragmaticworks
Pragmatic Works
7175 Hwy 17, Suite 2 Fleming Island, FL 32003
Phone: (904) 638-5743
Email: training@pragmaticworks.com
#PragmaticWorks
That’s cool! Been using SQL for almost 2 years now and love learning stuff like this!
Thank you . Was helpful for me :)
Thank you for sharing
Another way of doing this using CASE method is
select
ReleaseYear,
count(distinct case when Genre='Sci-Fi' then Title* else null end) as 'Sci Fi',
count(distinct case when Genre='Crime' then Title* else null end) as 'Crime',
count(distinct case when Genre='Romance' then Title* else null end) as 'Romance',
count(distinct case when Genre='Action' then Title* else null end) as 'Action',
count(distinct case when Genre='Drama' then Title* else null end) as 'Drama'
from movies
group by 1
order by 1;
* (Title or MovieId . either of the can be taken in case statement as both will be unique )
Interesting video, thanks. Just wondering though, is there a way to do dynamic pivoting, so that you don't have to type out the values in the columns - in the case where you have a lot of different values in the columns?