RE: Math equation in Oracle SQL

  • From: "Adrian Beech" <a.beech@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 23 Aug 2008 11:40:41 +1000

G'day,

If you have no conditional which associates the records between r1 and r2
then you will encounter a Cartesian product situation.  For example you will
need something in the form "Select ... from r1, r2 where r1.x = r2.x".

Does that make sense?

Cheers.
AB

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Eileen Lafond
Sent: Saturday, 23 August 2008 11:11 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: Math equation in Oracle SQL

Thanks for noticing the incorrect alias.  I corrected that and it works,
however, it appears to be in a loop or something because there are only 524
rows on the tables and it created over 200,000 output rows before I did a
control c to stop it.  

Do you have a clue what I have done wrong?  

My total code follows, but I am just testing the select statement before I
place the result in the actual field in the table.


updateRP08_R2_RETRO_PAY_SUM rp2 
set rp2.WO_RATIO_RATE  =
(select (rp2.RESOURCE_AMOUNT / rp1.TOTAL_PRECOLA_PAID) from
RP08_R2_RETRO_PAY_SUM rp2,  rp08_r2_empl_tbl rp1)

Thanks,






Eileen La Fond
Phone (206) 386-0011
e.mail Eileen.LaFond@xxxxxxxxxxx

>>> "Adrian Beech" <a.beech@xxxxxxxxxxxxxx> 8/22/2008 4:57 PM >>>
G'day,

You have aliased RP08_R2_RETRO_PAY_SUM as r2 and referenced it as rp2 in the
equation.  The statement seems to be truncated too so I'm not able to
determine if you've done the same with the rp1 reference.  Might I also
suggest you associate a name with the result of the equation as well.

HTH.

Cheers.
AB

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Eileen Lafond
Sent: Saturday, 23 August 2008 8:21 AM
To: programmingblind@xxxxxxxxxxxxx 
Subject: Math equation in Oracle SQL

I have to divide two fields and put the result in another field.  I am just
starting out with the select statement of the equation itself, but am
getting a strange error message.    I am putting the code and error mesage
here, if someone can assist me.

select (rp2.RESOURCE_AMOUNT / rp1.TOTAL_PRECOLA_PAID) from
RP08_R2_RETRO_PAY_SUM r2, rp08_r2_empl
        *
ERROR at line 1:
ORA-00904: "RP2"."RESOURCE_AMOUNT": invalid identifier
SQL> 
SQL> 

Thanks for any help,

Eileen La Fond
Phone (206) 386-0011
e.mail Eileen.LaFond@xxxxxxxxxxx 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind 


__________ NOD32 3381 (20080822) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com 


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind 


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind


__________ NOD32 3381 (20080822) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: