Home » SQL & PL/SQL » SQL & PL/SQL » How to add and multiply values in columns (APEX 4.2)
How to add and multiply values in columns [message #603602] Tue, 17 December 2013 13:50 Go to next message
brijeshgupta
Messages: 1
Registered: September 2013
Location: Bangalore
Junior Member
All,

I have created a table with 3 columns namely: Base Amount, Tax and Total. In theory Total would be the sum of the values entered by the user in the Base Amount and the Tax columns. How can we have the sum of the two populated in the Total Column without having to enter it manually.

Thanks in advance for your help!!!
Re: How to add and multiply values in columns [message #603603 is a reply to message #603602] Tue, 17 December 2013 14:39 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If TOTAL = BASE + TAX, why would you want to store it into a table? You can always easily calculate that number.

Therefore, I'd suggest you NOT to do that. You'd rather create a view which would display these three values. Or, if your database version supports it, create a virtual column in a table. If you insist (once again: don't do that), create a database trigger which would sum BASE and TAX values and store the result into TOTAL.
Re: How to add and multiply values in columns [message #603604 is a reply to message #603602] Tue, 17 December 2013 14:58 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

If you are in 11g you can use a virtual column for this "total AS (base+tax)"

Regards
Michel
Previous Topic: help me please to migrate from MS SQL to Oracle
Next Topic: Select query given ORA-01722 error message
Goto Forum:
  


Current Time: Fri Mar 29 08:15:03 CDT 2024