SQL convert Rows to columns

  • This was removed by the editor as SPAM

  • wburke 85918 wrote:

    Wow, that's a very good article Jeff, comparing Pivot to Cross Tabs. I was noticing all your Pivots always have aggregate functions. What I am doing seems to involve grouping more than math. So is there a way to use pivot that does not involve a aggregate. I know that's probably a dumb question.  One of our DBA's suggested I try Pivot like a year ago. At this point I feel like its been a wild goose chase, for this project at least. I have to know can it be used for what I am trying to do?

    To the best of my knowledge, No.  PIVOT in SQL Server requires aggregates.  You would have to use MAX in your PIVOT here.

    A very long time ago, I read up on the PIVOT operator in MS Access.  I don't recall the details but, when I read it, it seemed to be tons better than the monstrosity they landed in SQL Server.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply