MayFlower develops specialty software products for Lotus Notes & Domino.




Chapter 7 - Roll Up Totals with SQL
Table of Contents


If you want to roll up sales, you can do it. Remember that all the data will be summed according to the fields listed in the GROUP BY clause of the SQL statement. In this example, you would have one summary record per CompanyName, CompanyAddress and CompanyCity.

If you wanted sales by CompanyName only, it does not make sense requesting Address and City. That statement looks like:
SELECT Customer.CompanyName, SUM(Orders.SalesQ1) , SUM(Orders.SalesQ2), SUM(Orders.SalesQ3), SUM(Orders.SalesQ4) FROM Customers, Orders WHERE Customer.CustomerNumber = Orders.CustomerNumber GROUP BY Customer.CompanyName

If you wanted TotalSales, you could add a Notes formula that looks like:
Field TotalSales := SalesQ1 + SalesQ2 + SalesQ3 + SalesQ4

Note: Not all drivers support all functions. The Sentinel passes any failure codes bask to the user, and writes them to the Message Log for future reference.