database - Filemaker 13 calculations among unrelated tables -


i'm using database have several tables store information receipts , expenses.

what produce format put overall balance, i.e. (table1.receipts_total + table2.receipts_total) - ( table3.expenses_total + table4.expenses_total)

the main problem here these tables not related each-other , seems difficult deal aspect in filemaker.

i thought there way runa low-level "raw" sql statement, not able that.

first, suggest normalize data structure - since whatever current 1 hack.

anyway, it's quite easy figure want without using executesql() - run simple script like:

go layout [ table1.receipts ]  show records  set variable [ $balance; value:table1.receipts::stotalamount ]  go layout [ table2.receipts ]  show records  set variable [ $balance; value:$balance + table2.receipts::stotalamount ]  go layout [ table3.expenses ]  show records  set variable [ $balance; value:$balance - table3.expenses::stotalamount ]  

at point, $balance variable contain requested number, , can whatever want it.

note: stotalamount fields summary fields defined total of [amount] in each of 3 tables.


alternatively, relate 3 tables using x relational operator (i.e. create cartesian product relationship), use calculation, in table1.receipts table, =

stotalamount + table2.receipts::stotalamount - table3.expenses::stotalamount 

but not recommend place "live" calculation field on layout, increasingly slower number of transaction grows.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -