Home » SQL & PL/SQL » SQL & PL/SQL » Calculating values from two different tables by using SQL command. (Oracle 11g ver 11.2.0.1.0)
Calculating values from two different tables by using SQL command. [message #652688] Thu, 16 June 2016 06:26 Go to next message
faisal78
Messages: 1
Registered: June 2016
Location: Islamabad
Junior Member
Hi,
I have three different tables, student1, student2 and Total having fields.

student1 student2 ---> Total

sno sname Math Physics English sno sname Math Physics English ---> sno sname TotalMarks


I want to have calculated TotalMarks (Math+Physics+English) from student1 and studne2 in the Total table.
Please help me about, which SQL command I would use to do this.

Regards,

Faisal
Re: Calculating values from two different tables by using SQL command. [message #652690 is a reply to message #652688] Thu, 16 June 2016 06:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68045
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Show us what you already tried, it seems there is no problem to add 3 columns and put it in another one.

Re: Calculating values from two different tables by using SQL command. [message #652694 is a reply to message #652688] Thu, 16 June 2016 07:11 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
It is bad idea to store computed values in static tables, since base value may change.
Re: Calculating values from two different tables by using SQL command. [message #652697 is a reply to message #652694] Thu, 16 June 2016 08:10 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
I would make your totals table into a view. That way the values and rows will always be correct because they will reference the base tables.
Re: Calculating values from two different tables by using SQL command. [message #652699 is a reply to message #652697] Thu, 16 June 2016 08:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68045
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

But you wouldn't answer teacher's question. Smile

[Updated on: Thu, 16 June 2016 08:14]

Report message to a moderator

Re: Calculating values from two different tables by using SQL command. [message #652701 is a reply to message #652699] Thu, 16 June 2016 08:39 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
True, but they might get extra points for doing it correctly. LOL
Previous Topic: Removing specific line from file using UTL_FILE
Next Topic: Query table with multi part column names
Goto Forum:
  


Current Time: Sat Dec 04 06:05:15 CST 2021