Advertisement

02.15.2008 at 02:51PM PST, ID: 23167573
[x]
Attachment Details

sql subquery updating table rows with value of another field in table

Asked by Matila in SQL Query Syntax, Data Manipulation

Tags: sql

Updating a table using the results of subquery in table

this is what I want to accomplish
on AGT table
for all agts in the table, find the rgn cde and ovde ind for first record with term dte = 99999999. Then, use the value of the rgn cde & ovde ind to update any other rows for that ag that have different rgn cde & ovde ind.


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
what I have tried:
 
Update AGT B		
Set B.rgn = A.rgn, B.ovde = A.ovde, B.Lt_Chge = 'RTX',
B.Lt_Chnge_Dte = CURRENT_DATE, B.TimeStamp = CURRENT_TIMESTAMP
WHERE B.rgn NOT IN 
(select A.rgn from AGT A
where B.agt = A.agt 
and A.term_Dte = 99999999) 
 
received error message:
 S0022(-206)[IBM][CLI Driver][DB2/NT] SQL0206N  "A.rgn" is not valid in the context where it is used.  SQLSTATE=42703
 (0.00 secs)
 
 
Appreciate any suggestions. Thanks.
[+][-]02.15.2008 at 03:06PM PST, ID: 20906874

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.15.2008 at 03:58PM PST, ID: 20907145

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.15.2008 at 10:57PM PST, ID: 20908606

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 03:49AM PST, ID: 20909271

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 10:05AM PST, ID: 20910781

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 01:28PM PST, ID: 20911443

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 07:59PM PST, ID: 20912732

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 09:43PM PST, ID: 20913112

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 09:46PM PST, ID: 20913116

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 01:24AM PST, ID: 20913458

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 08:13AM PST, ID: 20914417

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 09:55AM PST, ID: 20914752

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 01:59PM PST, ID: 20915958

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 06:48PM PST, ID: 20917217

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 08:33PM PST, ID: 20917574

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, Data Manipulation
Tags: sql
Sign Up Now!
Solution Provided By: jinesh_kamdar
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628