Forum Replies Created

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

  • RE: More help wit Sum, Pivot and so on...

    John_P (3/5/2013)


    Looking at Thomas' select statement made me think of one of my favorite functions, that (IMHO) doesn't get enough use: SIGN

    Now, this only works here because there are...

  • RE: More help wit Sum, Pivot and so on...

    Problem solved! 🙂

    Here is the sql-statement that did the trick!

    SELECT *, (ISNULL(Denmark,0) + ISNULL(Finland,0) + ISNULL(Lithuania,0) + ISNULL(Norway,0) + ISNULL(Sweden,0)) /

    (CASE WHEN ISNULL(Denmark,0)>0 THEN 1 ELSE 0 END +

    CASE WHEN...

  • RE: More help wit Sum, Pivot and so on...

    Okey!

    I have come a bit on the way to a solution and have included a script for creating a test-table with sample dummy data in it!

    The result from the sql-statement...

  • RE: More help wit Sum, Pivot and so on...

    You need to calculate your averages using a GROUP BY and then add these back to your PIVOT.

    Here's a start on your sample data: "snip"

    SELECT Country, Manufacturer, MarketingName, AvgDropRate=AVG(DropRate)

    FROM @Phones

    GROUP...

  • RE: More help wit Sum, Pivot and so on...

    Phil Parkin (3/4/2013)


    Please follow the link in my signature to get details of how to post sample DDL, data and desired results to get the best response to your question.

    I´m...

  • RE: Help with SUM and Group By

    Hi Dwain!

    I´m dynamicly building my statement and adding and removing countrys from the sql-question on the fly depending on what filteroptions the user has choosen.

    I´m for the moment generating this...

  • RE: Help with SUM and Group By

    Solved!

    I got help from another forum and here is the answer that worked like a charm!

    You can use the PIVOT operator like shown below. If you have an unknown number...

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