# BAQ Running Sum

**URL:** <https://www.epiusers.help/t/baq-running-sum/67771>\
**Category:** Epicor ERP 10\
**Tags:** baq-runningsum\
**Created:** [June 3, 2020, 8:55pm UTC](https://www.epiusers.help/t/baq-running-sum/67771 "2020-06-03T20:55:21Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [June 4, 2020, 12:02pm UTC](https://www.epiusers.help/t/baq-running-sum/67771/6 "2020-06-04T12:02:10Z")

</div>

I think the `BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING` part might not be needed, or maybe overly specific. I think by default it uses only the previous row.

There’s some more good info in this post about how that code works.

> [@Perform a calculation on BAQ Summary Fields](https://www.epiusers.help/t/perform-a-calculation-on-baq-summary-fields/46937/12):
>
> I think you might be able to do this with a window function query. You can see an example with the system BAQ named: zGSTR1-B2B\_InvcDtl\_IN . If you change the ICE.QueryHdr.CGCode to an empty string you can load the BAQ in the designer and see how Epicor created it. What you want is to sum it over the group something like: SELECT CustNum, OrderNum, PartNum, SUM(UnitPrice\*OrderQty) OVER(PARTITION BY PartNum) AS SubTotal FROM ERP.OrderDtl; There is a ton of information on window functions here:…

---

_[View the full topic](https://www.epiusers.help/t/baq-running-sum/67771)._
