SUM of Two Columns from Two Different Table

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
mohamed
Veteran Member
Posts: 80
Joined: 2020-04-19 16:18

SUM of Two Columns from Two Different Table

Post by mohamed » 2020-09-29 15:19

Hello,

I have created 3 tables:
1. GSM (stored the user name)
2. Voice_Plans (stored both PLAN Number and Charges of the Plan)
3. Phones (stored Device Name and Charges of the Device

In the GSM table
- I have a Lookup field linked to `Voice_Plans`.`Charges`
- and I have another Lookup field linked to `Phones`.`Charges`
- and created another field with name TOTAL (to show the total of the above two fields that are linked to another two tables)

in CALCULATED FIELD I have entered the following SQL command:
SELECT (`Voice_Plans`.`Charges` + `Phones`.`Charges`) FROM Voice_Plans, Phones WHERE id='%ID%'

but I am not getting the TOTAL of the above two fields, so I am wondering;
1. If what I am intending to do is possible in Calculated Field

2. secondly, is the command correct ? :|
THANK YOU...
AppGini Pro 24.11 -
Calendar - Search Page Maker - Summary Reports - Mass Update - DataTalk -
bizzworxx AppGini Helper JabaScript Library - bizzworxx Inline Detail-View - bizzworxx Helper Pack - AppGini Helper Packaging Tool -
Udemy course

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: SUM of Two Columns from Two Different Table

Post by pbottcher » 2020-09-30 06:14

Hi,
1, yes,
2, no

:roll:

Without knowing the details of your tabledefinitons it is not possible to provide further help.

The sum is correct, but you need to join the 3 tables together based on the linked fields.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

mohamed
Veteran Member
Posts: 80
Joined: 2020-04-19 16:18

Re: SUM of Two Columns from Two Different Table

Post by mohamed » 2020-09-30 08:26

HI pböttcher,

You enjoy torturing me, isn't it?! :D

No worries, thanks for your comments and confirmation that it is possible 8-)

I am pushing Mr. GOOGLE to find me the solution or at least some hints, as SQL is not my play ground :)
THANK YOU...
AppGini Pro 24.11 -
Calendar - Search Page Maker - Summary Reports - Mass Update - DataTalk -
bizzworxx AppGini Helper JabaScript Library - bizzworxx Inline Detail-View - bizzworxx Helper Pack - AppGini Helper Packaging Tool -
Udemy course

Post Reply