Improve performance of product viewables.

Before this patch, this viewables were using a really long group by, and
that can be really slow when there is a lot of results, since grouping
requires sorting.

This patch will use subselects to do the sums, and that eliminates the group
by.

Change-Id: I48da4bc885cd633b5ebdaa704783821be0ec6368