CRM-13467 - using temp table for multiple inner joined queries
CRM-13467 - generalizing select-clause building and appending temp table
CRM-13467 - cleanup, order-by fixes
Merge pull request #1860 from deepak-srivastava/act-report

CRM-13467