• ocean3300 (7/19/2016)


    If you want to display sum(omlExtendedPriceBase) as 0 if the value is null, use ISNULL(SUM(omlExtendedPriceBase),0).

    That's one of the many reasons why I don't use PIVOT. A good ol' fashioned CROSSTAB, like what Luis used, will take care of that auto-magically. Please see the following URLs for why I personally never use PIVOT.

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

    http://www.sqlservercentral.com/articles/Crosstab/65048/

    --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)