473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Complex Update query

Hello everyone,

Please help me revise this query to make it work. I don't know much about update query so I will need some help with it. Thanks,


update encounter
set mergedpayment = totalactualcashpayments
from encounter E, paymentITEM P, encounterfinancialrecord F
where (E.encounterid = P.FINANCIALRECNUM) AND (E.encounterid = F.FINANCIALRECNUM) and (transtypecode = 'C') and (F.INSPLANCODE not in ('UNINSURED', 'SP', 'Selfpay'));
May 8 '06 #1
2 5792
cweiss
36
Try this:

Expand|Select|Wrap|Line Numbers
  1. UPDATE encounter E
  2. SET E.mergedpayment = (
  3.     SELECT <TableAlias>.totalactualcashpayments
  4.     FROM 
  5.        paymentITEM P, 
  6.        encounterfinancialrecord F
  7.     WHERE
  8.        E.encounterid = P.financialrecnum AND
  9.        E.encounterid = F.financialrecnum AND
  10.     <TableAlias>.transtypecode = 'C' AND 
  11.        F.insplancode NOT IN('UNINSURED', 'SP', 'Selfpay'));
May 10 '06 #2
It worked!! Thank you so much.


Try this:

Expand|Select|Wrap|Line Numbers
  1. UPDATE encounter E
  2. SET E.mergedpayment = (
  3.     SELECT <TableAlias>.totalactualcashpayments
  4.     FROM 
  5.        paymentITEM P, 
  6.        encounterfinancialrecord F
  7.     WHERE
  8.        E.encounterid = P.financialrecnum AND
  9.        E.encounterid = F.financialrecnum AND
  10.     <TableAlias>.transtypecode = 'C' AND 
  11.        F.insplancode NOT IN('UNINSURED', 'SP', 'Selfpay'));
May 10 '06 #3

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

Similar topics

4
by: Christoph Bisping | last post by:
Hello! I'm seeking advice on a rather complex type of query I need to build in an Access ADP (SQL-Server 7). There are four tables: tblPeople ID(PK) PRENAME --------------- 1 Thomas 2 Frank
1
by: ravi | last post by:
I have created the following interest to calculate the interest for the following currency pairs. I have tried to combine them in macros using conditions but the next query that is run in the macro...
6
by: someguy | last post by:
Hi, I'm trying to accomplish the following on a form on which i have removed navigational buttons (I apologize in advance if this is too many questions); The two easy ones are.... 1) When...
1
by: Joe | last post by:
Dear Friends, How do write the below dynamic update Query? I am new to this SQL Query.Its very very urgent requirements. If anyone knows please help me the below SQL query. I would appreciate...
2
by: Ben de Vette | last post by:
Hi, I'm using the querybuilder when updating a record in a table (Access). However, I get a "Query is too complex" message. The Primary key is autonumbered. Why is it making such a complex...
1
by: Mark Dexter | last post by:
In Microsoft SQL Server, I can write an UPDATE query as follows: update orders set RequiredDate = (case when c.City IN ('Seattle','Portland') then o.OrderDate + 2 else o.OrderDate + 1 end)...
3
by: Slower Than You | last post by:
I am trying to write an SQL UPDATE statement for an MSAccess table and am having some problems getting my head around it. Can anyone help? TableName: CustTransactions TransactionKey AutoNumber ...
1
by: koehlerc14 | last post by:
So here is the deal, I am attempting to make what is the most complex form i have made yet. It really is not much, but as an amatuer it is a little overwhelming. Here's a few critical background...
1
by: Rudolf Bargholz | last post by:
Hi, We have created triggers to log modifications to tables in our application. The triggers work fine, just on one of the tables in our database the triggers fail with the error message...
11
by: sloney | last post by:
Hello All! I have an update query that is rather large and I keep getting a "Query is too complex" error. Does anyone know the limitations on update queries for MS Access 2000? I am running on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.