Select Query Question

  • I have two tables with a 0-to-many relationship.  Contract (ContractID, ....) and CustRelationship (ContractID, CustID, CustPercent).  CustRelationship has multiple rows that point back at Contract.  Is it possible to get all the CustID's into a single row for each Contract?

    Example:

    ContractIDCustIDCustPercent
    12341250.00
    12345425.00
    12347425.00
    .........

    Output
    1234125474
    ............

    Thanks.

  • Yes. It is called PIVOT or CROSSTAB queries.

    There are examples of this in Books Online.

    Or have a look at

    http://www.sqlservercentral.com/columnists/plarsson/pivottableformicrosoftsqlserver.asp

     


    N 56°04'39.16"
    E 12°55'05.25"

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

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