473,503 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating a column based on value in another table

2 New Member
Can anyone see what's wrong with this update statement? It works on my DB2 database, but not on my Oracle 9i database. Any help would be much appreciated. Thx, Coleen

I want to set PLDG_BILL_AMT = the sum of its gifts divided by the nbr of its gifts
Expand|Select|Wrap|Line Numbers
  1.  
  2. update SUMMIT.PLDG a 
  3. set a.PLDG_BILL_AMT = ((select sum(b.GIFT_AMT) from SUMMIT.GIFT b where a.PLDG_NUM = b.PLDG_NUM) / (select count(*) from SUMMIT.GIFT c where a.PLDG_NUM = c.PLDG_NUM))  
  4. where a.PLDG_NUM = 2
  5.   AND a.PLDG_BILL_AMT = 0 
  6.   AND a.PLDG_NUM in (select b.pldg_num from SUMMIT.GIFT b where a.PLDG_NUM = b.PLDG_NUM);
  7.  
Mar 21 '08 #1
1 1920
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Try This :

Expand|Select|Wrap|Line Numbers
  1. update SUMMIT.PLDG a 
  2. set a.PLDG_BILL_AMT = (select sum(b.GIFT_AMT) / count(*)  from SUMMIT.GIFT b where a.PLDG_NUM = b.PLDG_NUM Group By  b.PLDG_NUM Having Count(*) >0 )  
  3. where a.PLDG_NUM = 2
  4. AND a.PLDG_BILL_AMT = 0 
  5.  
Regards
Veena
Mar 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
6152
by: cyoung311 | last post by:
I'm trying to do an automatic update of one table from another through a form. Basically, when a selection is made for an item, in this case a particular workshop, I want to get the associated...
5
1707
by: J. Yuan | last post by:
Hi, I am working on a checkout/inventory system. How can I make a button that when pressed, would update the previous fields transaction number to a table (for example, -3 printers, so that...
2
2368
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
3
12996
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be...
4
2360
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
1
2201
by: abefuzzleduser2 | last post by:
we use Access 2000 with linked tables in SQL Server 2000. I have a form and a datasheet subform based on a table. This was not related to the parent table before and I was changing nvarchars to...
33
3254
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
10
2216
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
9
4974
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
9
2507
by: hrreece | last post by:
I have an Access 2002 database that has a form that can be used to review individual records. At the bottom of the form are buttons that are linked to functions that allow the user to "Find a record...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.