how to get count of combination for multiple rows

  • Hi

    My application need at least 2 approval for an request.

    I need to generate a report to count which combinations are the most.

    example

    ApplicationIDDateTimeApprovalUserID

    110/10/20121

    110/10/20122

    110/10/20123

    211/10/20121

    211/10/20123

    312/10/20122

    312/10/20123

    413/10/20121

    413/10/20122

    514/10/20121

    514/10/20123

    615/10/20121

    615/10/20123

    716/10/20121

    716/10/20122

    My report should show

    Approval1Approval2Approval3Count

    1231

    122

    133

    231

    I manage to the the result like above but without the COUNT.

    I really no idea how to make script work. Please help.

  • wailoon.ho (10/22/2012)


    Hi

    My application need at least 2 approval for an request.

    I need to generate a report to count which combinations are the most.

    example

    ApplicationIDDateTimeApprovalUserID

    110/10/20121

    110/10/20122

    110/10/20123

    211/10/20121

    211/10/20123

    312/10/20122

    312/10/20123

    413/10/20121

    413/10/20122

    514/10/20121

    514/10/20123

    615/10/20121

    615/10/20123

    716/10/20121

    716/10/20122

    My report should show

    Approval1Approval2Approval3Count

    1231

    122

    133

    231

    I manage to the the result like above but without the COUNT.

    I really no idea how to make script work. Please help.

    I am not really sure what you want here. Can you post ddl and sample data along with the desired output. Take a look at the first link in my signature about best practices when posting questions.

    _______________________________________________________________

    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/

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

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