Handle a SUM and COUNT through 3 GROUPINGS.
Posted on 2013-11-07
Can you suggest if the below can be bettered or simplified.. the logic is as below:
The first 3 queries are put into 3 temp tables A B and C. The only difference between the 3 queries are in the HAVING clause.
Because we are doing a SUM on Col10, I was not able to do a COUNT on another column (Col0) on the same query.
So I am doing my count on Col3, in three seperate queries from A, B, C temp tables - doing a UNION on them, and then grouping them again with 3 SUM operations.