Take a look at the beginning of this query:
SELECT
sum(decode(REGEXP_COUNT(tpdd.domain, 'thedomain.com'), 1, tpdd.size, 0, 0)) SizeClient,
sum(decode(REGEXP_COUNT(tpdd.domain, 'thedomain.com'), 1, 0, 0, tpdd.size)) SizeThirdParty,
...
Is there a way to reuse the results of the "REGEXP_COUNT(tpdd.domain, 'thedomain.com')" function? I should hope that the oracle server is smart enough to do that but I can't guarantee it, and besides, the code would look better without the repeated code.
tpddsubquery (or transform thetpddquery into an inline view and add that). I wouldn't expect any vaguely recent version of Oracle to recompute the function call, however.