Question

Asked on 2008-11-15 at 05:10:56ID: 25465746

INCORRECT SUM WHEN ADDING MULTIPLE COLUMNS IN ORACLE

by: douglegs125

Rating9.8Excellent

I have some tables in a DB and am creating a view to show the profit of the company.
One of the tables (CHARGEEVENTS) holds details of Fixed charges and Variable Charges (2 columns)
Another Table (BOOKINGS) holds details of booking costs (revenue)
I can query each of these successfully and get the correct result.
I am trying to derive Revenue-Costs as a single value.  I get a result (ie the SQL syntax is valid) but it is not correct.  Any Ideas?

This is my query code:

SELECT 
    SUM(FIXEDCHARGE+VARIABLECHARGE)-SUM(BCOST) AS PROFIT
FROM
CHARGEEVENTS, BOOKINGS
                              
1:
2:
3:
4:

Select allOpen in new window

  1. Oracle -- SQL Select "Where Sum <> 1"
    Doing the below WHERE statement causes a "group function is not allowed here" error. How can I fix ? SELECT FMFORMULAID, SUM(FMWEIGHTPCT) FROM FMFORMULAEXPANDED Where SUM(FMWEIGHTPCT) <> 1 GROUP BY FMFORMULAID
  2. How to display row values as column headers, …
    In an Oracle database I have a table with rows such as.. Month | Name | Job | Val --------------------------------- January | Mr Smith | Job 1 | 50 January | Mr Smith | Job 3 | 50 January | Mr Jones | Job 2 | 50 February | Mr Jones | Job 4 | 50 February | Mr Smith …
  3. how to identify when a column was modified
    Hi, Can someone help me understand how to identify when a column datatype/lenth was modified in the table? Is that possibe?
  4. Add a new Column in a table
    Hi Experts, I want to add a new Column called ID as the first column to the table structure shown in the snapshot. How to do this? But the main requirement is, I want this ID column to be dynamic, like, whenever a new row is inserted a new ID get assigned. is it possible to do? Like row 1 would have ID values as …
  5. Need Sum of Column based on Location and Level
    Hello, I'm trying to get the sum of a column that's being generated earlier in the query and have it be the sum of individuals based on their location and level. So TotalPaid is the the pay of one individual based in 'Wisconsin' and he is a 'Level 1'. There are two locations ( Wisconsin and New York) and three levels (level 1, level 2, and l…

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution
View This Solution - Start Your 30 Day Free Trial
Zone
General
Tags
SQL ORACLE
Participating Experts
2
Solution Grade
A

Replies

 by: angelIII

Posted on 2008-11-15 at 05:14:50ID: 28269678

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: douglegs

Posted on 2008-11-15 at 05:16:56ID: 28269679

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by:

Posted on 2008-11-15 at 05:17:46ID: 28269680

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: tigin44

Posted on 2008-11-15 at 05:18:25ID: 28269681

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: douglegs

Posted on 2008-11-15 at 05:29:21ID: 32743319

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Stay Connected

Oracle Around the Web

The latest Oracle news, tips, and tricks

Oracle Unveils Netra SPARC T3 Servers

New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...

read more

Oracle fixes 21 flaws in Java SE, Java for Business

Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...

read more

Obama’s Silicon Valley “Tech Supper”

Why was he there? Who wasn’t invited and why? What did they talk about? Why was he really there? These are the questions being debated ...

read more

Featured Oracle Experts

slightwv

slightwv has answered more than 2,000 Oracle questions and oversees database management within the U.S. Government. Slightwv

sdstuber

A regular presenter at the Collaborate conference, Oracle developer sdstuber is a top expert in PL/SQL and Oracle 9, 10 and 11. sdstuber

Testimonials

What users are saying about our experts

"The Oracle gurus provide answers, solutions and valuable workarounds"

User: schwertner

"Wow! Excellent, valuable explanation. Hats off to you"

User: aseshu70

"Solution worked fantastic and performs excellent! Thanks heaps"

User: klausbrandlhuber

Top Experts

  1. slightwv

    2,000

    0 points yesterday

    Profile

BrowseBecome an Expert