Advertisement

05.02.2001 at 01:08PM PDT, ID: 20112624
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

USING SUM FUNCTION WITH A BASIC SELECT STATEMENT WHILE CREATING TABLES/VIEWS

Asked by hayub in Oracle Database

Tags: , ,

I am trying to create a view/table, which is fecthing records from five different tables, and I need to calculate the sum of these fields in such a way that two tables have more than one value to add and I'm using SUM function to add their values. The SELECT statement looks something like that:

     
create table total_dues
as select
a.name,a.membership_no,(b.due+sum(c.due)+d.due+e.regn_cg_due+sum(f.surcharge_due))"Total Dues"
from member a,land_cost b, dev_charges c,fee d, regn e,surcharge f
where a.membership_no=b.membership_no
and
a.membership_no=c.membership_no
and
a.membership_no=d.membership_no
and
a.membership_no=e.membership_no
and
a.membership_no=f.membership_no
group by a.name,a.membership_no,b.due,d.due,e.regn_cg_due
/

The strange thing, which I have observed is that whenever SUM function is used more than once in the SELECT statement (as in the present case), the result is not correct i.e., the calculated sum of the fetched fields is always greater than the actual amount and when I skip one SUM function from the statement, the result is correct. This happens both in the case of creation of table and view. Why is that? Is something wrong with the syntax?
          Another interesting thing is observed in the following simple SELECT statements used on the Oracle supplied sample tables:
select sum(sal),sum(dept.deptno)
          from emp,dept
               where emp.deptno=dept.deptno
 In this particular case, the column sum(sal)gives the correct figure, while the column sum(dept.deptno) alwas gives the sum of deptno from emp table, even when I have used the dot notation to reference the dept table.
     Should I rely on the Report Builder to design a report, because in this particular case we are calculating the sum of fields fetched from five different tables. The summary column in Report Builder only sums the fields from one individual table. Could you please guide me in the repect.
Thanks
Hassan Ayub
Start Free Trial
 
 
Loading Advertisement...
 
[+][-]05.02.2001 at 03:27PM PDT, ID: 6047699

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2001 at 10:28PM PDT, ID: 6048302

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.03.2001 at 07:36AM PDT, ID: 6048576

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.03.2001 at 09:13AM PDT, ID: 6048886

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.03.2001 at 10:12AM PDT, ID: 6048931

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.03.2001 at 10:22AM PDT, ID: 6048956

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2001 at 05:50AM PDT, ID: 6050896

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2001 at 12:35PM PDT, ID: 6051725

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2001 at 05:19AM PDT, ID: 6054756

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.08.2001 at 05:47AM PDT, ID: 6058776

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: function, sum, select
Sign Up Now!
Solution Provided By: sidcap
Participating Experts: 4
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32