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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Cross Tab Data

Cross Tab Data

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
3 Posts 3 Posters 1 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi experts I am using SQL Server 2005 I have Table Having Str. like __________________________ Heading | Tax __________________________ A | Taxx A | Taxz A | TAXN B | 10 B | 20 B |30 C |5 C |5 C |4 _____________________________ i Want Result like -------------------------------- A B C ---------------------------------- TaxX 10 5 TaxZ 20 5 TaxN 30 4 -------------------------------- The No's of Column also dynamic i.e A B C D .... so on then help but Query in Using to get this Result Dinesh

    J M 2 Replies Last reply
    0
    • L Lost User

      Hi experts I am using SQL Server 2005 I have Table Having Str. like __________________________ Heading | Tax __________________________ A | Taxx A | Taxz A | TAXN B | 10 B | 20 B |30 C |5 C |5 C |4 _____________________________ i Want Result like -------------------------------- A B C ---------------------------------- TaxX 10 5 TaxZ 20 5 TaxN 30 4 -------------------------------- The No's of Column also dynamic i.e A B C D .... so on then help but Query in Using to get this Result Dinesh

      J Offline
      J Offline
      Jerry Hammond
      wrote on last edited by
      #2

      I believe you're looking for something like the following:

      USE AdventureWorks
      GO
      SELECT VendorID, [164] AS Emp1, [198] AS Emp2, [223] AS Emp3, [231] AS Emp4, [233] AS Emp5
      FROM
      (SELECT PurchaseOrderID, EmployeeID, VendorID
      FROM Purchasing.PurchaseOrderHeader) AS p
      PIVOT
      (
      COUNT (PurchaseOrderID)
      FOR EmployeeID IN
      ( [164], [198], [223], [231], [233] )
      ) AS pvt
      ORDER BY VendorID;

      "My interest is in the future because I'm going to spend the rest of my life there." - Charles F. Kettering

      1 Reply Last reply
      0
      • L Lost User

        Hi experts I am using SQL Server 2005 I have Table Having Str. like __________________________ Heading | Tax __________________________ A | Taxx A | Taxz A | TAXN B | 10 B | 20 B |30 C |5 C |5 C |4 _____________________________ i Want Result like -------------------------------- A B C ---------------------------------- TaxX 10 5 TaxZ 20 5 TaxN 30 4 -------------------------------- The No's of Column also dynamic i.e A B C D .... so on then help but Query in Using to get this Result Dinesh

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        This may help Pivot article[^]

        Never underestimate the power of human stupidity RAH

        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