Newbies Sam Reicht Posted June 26, 2016 Newbies Posted June 26, 2016 Hi, I need help with SQL and Running Total (instead of Total). TABLES INV = Invoice table - INV::Amount ( Amount of Invoice) - INV::DateMonth ( Month of InvoiceDate) - INV::DateYear ( Year of InvoiceDate) DTE = Months table (fixed 12 records) - DTE:Order=1...12) - DTE::CurYear = 2016 Below SQL request works, see my result! But what I would require is a running total, adding each month sales total, see my "Required result" ExecuteSQL ( " SELECT SUM(a.\"Amount\"/1000) FROM \"DTE\" b LEFT JOIN \"INV\" aON b.\"Order\" = a.\"DateMonth\"AND b.\"CurYear\" = a.\"DateYear\"GROUP BY b.\"Order\""; " | " ; "0¶" ) My current result as above SQL request 726.605050 818.7150 739.0678500 703.7210 620.805350 599.986160 506.9230 597.8370 801.78250 1014.11510 567.64575 Below is what I require (a Running Total)726.605051545.320052284.38792284.38792988.10893608.914254208.900414715.823415313.660416115.442917129.558017697.20376 I can do this without SQL, but I want to do using SQL and use it for my Charts. Would appreciate any help. My SQL understanding is basic and I am using FileMaker 14 Adv
Wim Decorte Posted June 26, 2016 Posted June 26, 2016 2 minutes ago, Sam Reicht said: I can do this without SQL, but I want to do using SQL and use it for my Charts. Why? What is your assumption about SQL being better?
Newbies Sam Reicht Posted June 26, 2016 Author Newbies Posted June 26, 2016 Hi Wim, Thanks for your interest. Its not better. But I can put the SQL statement inside the chart and show multiple charts at the same time on a single Layout! Without any additional fields, variables, relations etc.
beverly Posted September 14, 2016 Posted September 14, 2016 if you can get the data without SQL, then store in variables for your charts. otherwise, see if this self-join example gives you clues https://www.wagonhq.com/blog/running-totals-sql
Recommended Posts
This topic is 3265 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now