How to Pivot Your Data in T-SQL for SQL Server - Static and Dynamic Column Examples

Sdílet
Vložit
  • čas přidán 6. 09. 2024

Komentáře • 10

  • @dads_random_projects
    @dads_random_projects Před 10 měsíci +1

    Such a great video Sean! I have saved this in my SQL favs to reference as and when needed! This actually solves an issue I have now. I have followed along and so far so good. I am at the point where i need to creat my own version of the @myquery string. One question are you using the + as a line break as you would when line breaking a string in VBA? Thx again Sean.

    • @dads_random_projects
      @dads_random_projects Před 10 měsíci +1

      and BOOM... Got it working :). I originally tried using too many CTEs and got myself in a muddle. Switched to sub queries and it worked a treat. Thx Sean!

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Před 10 měsíci

      Awesome that you got it working! In this one I believe I'm using the + like you would use & in VBA: to concatenate the string. Thanks for bookmarking - you know what's funny is that sometimes I watch my own video because I forgot how I did something before.. lol!

  • @luismatos684
    @luismatos684 Před rokem +1

    Wow, easier, simple. Thanks!

  • @joannanowacka
    @joannanowacka Před 2 lety +1

    Thank you so much, first video that helped me solve my problem with pivoting :)

  • @filibertogarced
    @filibertogarced Před 2 lety +1

    Thank you Sean !

  • @mittapalliniveditha416
    @mittapalliniveditha416 Před rokem +1

    Hi, I have a question, the data which is generated using aggregation in pivot, can we modify the data into another format. for example, if we have 0's and 1's in the data i need to replace them with desired format like 0 to NO, 1 to Yes . Can you please help

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Před rokem

      One easy solution is to make a query that uses your cross tab as a source. For that column just use IIF in your query for that column. Ie. if it is 0 then No else Yes. See my video on iif