Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Pivoting in SQL

Pivoting in SQL

Scheduled Pinned Locked Moved Database
databasehelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anandkumar Prajapati
    wrote on last edited by
    #1

    Anyone can please help me to understand pivoting in SQL

    Richard DeemingR 1 Reply Last reply
    0
    • A Anandkumar Prajapati

      Anyone can please help me to understand pivoting in SQL

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Using PIVOT and UNPIVOT - SQL Server | Microsoft Docs[^] Questions About Pivoting Data in SQL Server You Were Too Shy to Ask - Simple Talk[^] SQL SERVER - PIVOT and UNPIVOT Table Examples - SQL Authority with Pinal Dave[^] Google (or your preferred search engine) will find you lots more.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      R 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Using PIVOT and UNPIVOT - SQL Server | Microsoft Docs[^] Questions About Pivoting Data in SQL Server You Were Too Shy to Ask - Simple Talk[^] SQL SERVER - PIVOT and UNPIVOT Table Examples - SQL Authority with Pinal Dave[^] Google (or your preferred search engine) will find you lots more.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        R Offline
        R Offline
        realJSOP
        wrote on last edited by
        #3

        We have a couple of tables that we have to un-pivot - one has 245+ columns and (on average) about 510k rows - it needs to be un-pivotted down to 8 columns, and the columns we need to pivot are a mix of int, float, and varchar. This means we have to cast all of the pivoted columns to varchar, and then re-cast in the unpivot clause. When we redesign the database (soon I hope), we won't have to un-pivot, but will instead have to pivot the columns into a schema the app can understand. Hopefully though, we won't have to do any un-pivoting/pivoting at all - it's a pretty expensive operation.

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups