Can't use 'Group By'

  • I am writing a report where I need to return a list of all cases an 'agent' was involved in, for each agent in the dept, as well as some summary statistics.

    Each row in my datasource represents a 'case'. Up to two agents can be involved in a case, so there is a column 'agent1' and a column for 'agent2' in each row.

    Since I cannot group on agent, I am wondering what is the best way to accomplish this?

    Should I write a report where the agent ID is a parameter and then just run/write a script to run the report for every agent ID?

    Or is there a better way to do this?

  • Or is there a better way to do this?

    2 agents in one row is not normalized data. Split the agents out into a separate table, and you'll find that your query now just auto-magically flows together nicely.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

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

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