• cms9651 (9/6/2012)


    The rule for the sorting is mat geographic NAME.

    MAW = My Area West

    MAE = My Area East

    MAC = My Area Center

    MAS = My Area South

    Ahh there is the challenge you were running into. You didn't have anything to order by.

    Try this.

    ORDER BY [DVD] DESC, CASE WHEN MAT = 'Tot' THEN 1 ELSE 0 END, CASE MAT when 'MAW' then 0 when 'MAE' then 1 when 'MAC' then 2 when 'MAS' then 4 end

    yep as I was typing Eugene posted pretty much the same thing. 😀

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/