A problem here is that you are violating the Single Value Rule in that you are grouping only by R.Rep_Name
yet selecting other fields without introducing them via an aggregate function, e.g. columns O.Orders
and C.response_time
(and the derived columns via Coalesce
and Concat
)
Because of this violation, it is likely that not all values of the non-grouped, non-aggregated columns have the same values per Rep_Name
group, and the result is indeterminate. More here
Edit(from comments below)
data looks a little better, but some rep_names are repeating
This appears to confirm the non-aggregated columns were not unique. So:
- either the columns can't be shown in the context of
rep_name
groups, - or you have more discrete groups than you thought
- or you will need to qualify the non-distinct columns with an aggregate such as
Count(O.Orders), AVG(C.response_time)
etc and then change the column headings as such (e.g. "TotalOrders", "AverageResponseTime" etc)