Question

INCORRECT SUM WHEN ADDING MULTIPLE COLUMNS IN ORACLE

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. Detail on Oracle Bug/Patch 6646853
    I would like some detail on what is fixed with the above Oracle Bug/Patch release. I know this much - 6646853- MLR BUG FOR 10.2.0.3 FOR CPUJAN2008. What does MLR stand for? I do not have access to MetaLink.
  2. How can I update a column in Oracle table
    How can I update a column in Oracle table following this logic: Oracle table T1 has columns name1 name2 date and status if name1 and name2 are repeated then update status from status which has the latest date. before the update name1= A , name2= B ,date=1/1/2009, status=ok name1= A , name2=B , date…
  3. how to convert rows into column in oracle
    how to convert rows into column in oracle
  4. 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
  5. Trying to add column to existing table.
    Trying to add column to existing table.(Oracle 10 g) 1) This table has existing records 2) Also need to rename this table. 3) While making this addition can I specify default values for this new column for existing record. 4) And For all future new insert to this table can we restrict the possible values for this column.

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

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

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:

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

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

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