• cms9651 (9/6/2012)


    Eugene Elutin (9/6/2012)


    The MAT column will be ordered randomly, but Tot will still come as a last one per DVD.

    I agree, that setup needs clarification about Total: is it already in a table or needs to be calculated?

    thank you for help.

    Total is it already in a table TestTable (in post #1 I have posted the CREATE TABLE [dbo].[TestTable] code).

    I tried your query but I have this incorrect output:

    MATDVDSALES

    MACL123

    MAEL123

    MASL123

    TotL129

    MACL011

    MASL014

    TotL015

    I need this:

    MATDVDSALES

    MAEL123

    MACL123

    MASL123

    TotL129

    MACL011

    MASL014

    TotL015

    Right and I have said repeatedly we need to understand what the rule for the sorting is. The only difference is that MAE is before MAC. What makes up the rule for ordering?

    _______________________________________________________________

    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/