Sum Outside of Subquery

Larry Beasley shared this idea 20 months ago
Idea Logged

I'm requesting that if I use a subquery and the column used to join the subquery to the master is not pulled into the display field and an aggregate is used then perform the aggregate outside of the subquery. This is why. If I append a view to the master and let's say that I use master.date <= subquery.date but all I want is the sum(balance) where master.date <= subquery.date then what will happen is the subquery will group by subquery.date thereby causing a cross join on the two dates. Again, the only column actually pulled in is balance. I'm proposing that there be some way for me to either choose to sum after the subquery so that the initial select statement looks like:

SELECT 
   T0.C0,
   T0.C1,
   T0.C2,
   T2.C1,
   T1.C2,
   SUM(T3.C2) T3.C2
FROM (....

Comments (1)

photo
2

Hi Larry,

yes indeed, that's a good one for sure!

So I've raised an internal enhancement request for it (YFN-10609).

As always, thank you for your contribution.

regards,

David