PIVOTS and TRANSFORMS

  • Lets say for example that you're working on a database to manage projects. You have a main table that has the general project information, a table for key persons assigned to the project and a table of key dates. Is there a way to present the information in a grid-type view as in...

    |--Project Information----| |---------------------Key Dates---------------------------| |-----Staff-----|

    Project Name Funding Date Requirements UAT Implementation BSA QA Lead

    SQL Server Upgrade 10/1/2008 12/1/2008 5/1/2008 DCH FSL

    ASP Integration 2/15/2009 8/6/2009 DCH

    Project Information is the parent with Key Dates and Staff being children all in a one-many relationship. Records in the Key Dates would be unique in that there could only be (1) Funding Date, however the Staff table might have multiple records allowing for more than 1 BSA, QA Lead, etc.

    Where would I information that discusses how to write the SQL statements?

    I did read an article that showed how to ensure the same number of columns when using PIVOT or TRANSFORM (I don't remember the specific keyword).

  • May I refer you to Jeff Moden's excellent articles here in SSC

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    http://www.sqlservercentral.com/articles/cross+tab/65048/

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Thanks Ron :blush:

    --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 3 posts - 1 through 2 (of 2 total)

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