Sum Outside of Subquery

Larry Beasley shared this idea 6 years ago
Completed

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 (....

Replies (2)

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

photo
1

Hi Larry,

Just letting you know this item has now been implemented in the latest 9.7.1 release,

Information on this new feature can be found here.

If you have any questions or issues with this, please let me know.


As always, please keep the feedback coming!


Thanks,David

Leave a Comment
 
Attach a file