SQL Server 2005 for SQL2k Developer (Part 1)?

  • Muhammad Choirul Amri

    SSC Veteran

    Points: 207

    Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/mcAmri/sqlserver2005forsql2kdeveloperpart1.asp

  • Duray AKAR

    SSC Veteran

    Points: 261

    Clean and clear demonstration of such a useful feature...

    Thank you

  • ed_elfrink

    SSC Journeyman

    Points: 75

    I look forward to more...thanks!

  • Paul E

    SSC Enthusiast

    Points: 134

    Thanks for the examples.  In case anyone is working through them, the case statement has a typo with a '2002' replaced with a '2001'

  • Jim Brady

    SSC Rookie

    Points: 31

    Thankyou I found your article very helpful and presented in a clear style. I look forward to reading more of your work

     

  • Muhammad Choirul Amri

    SSC Veteran

    Points: 207

    Hi Paul,

    thanks for the correction of the typo.

    The query still works fine, but order year 2001 will be interpreted as 2002 .

    It should be like this:

    SUM(CASE when OrderYear = 2002 then SubTotal ELSE 0 end) as '2002',

  • Sunil Lathar

    Valued Member

    Points: 53

    i look farward for more. thanks !


    slathar

  • Muhammad Choirul Amri

    SSC Veteran

    Points: 207

    Hi All,

    I'm working on second installment of this series now. Just wait

  • Pam Brisjar

    SSChampion

    Points: 12094

    Good intro. Thanks. 

    I've got a question, though.  Given this statement from your article:

    INSERT INTO SalesByPerson

    SELECT SalesPersonID, [2002],[2003],[2004] FROM Sales.SalesSummarry

    PIVOT(SUM(SubTotal) FOR OrderYear IN

    ([2002],[2003],[2004])) as SalesPivot

    is the IN (.....) required?  What if I don't know the values and/or the values change?  Am I stuck with dynamic SQL?  Could I maybe put a sub-query (i.e. select DISTINCT OrderYear) in there?

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

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