Results 1 to 2 of 2

Thread: Cross Tab?

  1. #1
    Join Date
    Feb 2004
    Posts
    134

    Unanswered: Cross Tab?

    I need to format the following tables:

    Code:
    tbEmployees
    EmployeeID | fName        | lName
    -------------------------------------------
    jdoe          | Joe            | Doe
    bsmith       | Blake          | Smith
    
    tbDepartments 
    DepartmentID | Department
    -------------------------------
    ENG              | Engineering
    DET              | Detailing
    
    tbDepartmentEmployees
    fkEmployee ID | fkEmployeeID
    ------------------------------
    ENG               | jdoe
    DET               | bsmith
    
    tbProjects 
    ProjectID | 
    ---------------
    1001
    
    tbProjectTeam 
    fkProjectID | fkEmployeeID | fkDepartmentID
    -------------------------------------------
    1001         | jdoe             | ENG
    1001         | bsmith          | DET
    To the following view :

    Code:
    vProjects
    ProjectID  |  Engineer        | Detailer
    -------------------------------------
    1001        | Joe Doe          | Blake Smith
    Any Ideas?
    Mike B

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    SQL server does not have built-in crosstab querys as Access does. You can replicate a cross-tab query using CASE statements. It looks intimidating at first, but it actually pretty straight-forward. Look up Crosstab in Books Online for a good explanation and example.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •