I have a table T(col1, col2, col3, col4) and I run sub-queries on it that results on two disjunct sets of data. Now I have to update col2 from the first set of data to the values from col3 of the second subquery.
How should the update query be?
I tried something like
update subset_d set subset_d.col2=subset_c.col3
where d.col1=c.col1 and
d.col4=d.col4
The subset_c and subset_d are run on the same table
In my situation the table HORATIU_NETWORK_AREA and the subqueries are d and c. The query I tried is -
-
update d set d.eff_stop_ts= c.eff_start_ts from
-
(
-
select a.NETWORK_AREA_ID, a.CELL_ID, a.LAC_ID, to_char(a.EFF_STOP_TS,'dd-mm-yyyy hh:mi:ss'), a.TIME_ZONE_CD, a.BID, to_char(a.EFF_START_TS,'dd-mm-yyyy hh:mi:ss'), a.NETWORK_AREA_PROV_STATE_CD, a.NETWORK_AREA_CITY_NM, a.SWITCH_ID, a.CREATE_USER_ID,a.LAST_UPDT_USER_ID, to_char(a.CREATE_TS,'dd-mm-yyyy hh:mi:ss'), to_char(a.LAST_UPDT_TS,'dd-mm-yyyy hh:mi:ss')
-
from
-
HORATIU_NETWORK_AREA
-
-
a,
-
(
-
select hna1.CELL_ID, hna1.LAC_ID, count(*) from
-
HORATIU_NETWORK_AREA hna1
-
-
group by hna1.CELL_ID,hna1.LAC_ID having count(*)>1
-
) b
-
where
-
a.cell_id = b.cell_id and
-
a.lac_id=b.lac_id and
-
a.eff_stop_ts >= to_date('01-01-2029 00:00:00', 'dd-mm-yyyy hh24:mi:ss') and
-
a.eff_stop_ts <= to_date('01-01-9999 00:00:00', 'dd-mm-yyyy hh24:mi:ss')
-
order by a.cell_id, a.lac_id
-
) d,
-
(
-
select a.NETWORK_AREA_ID, a.CELL_ID, a.LAC_ID, to_char(a.EFF_STOP_TS,'dd-mm-yyyy hh:mi:ss'), a.TIME_ZONE_CD, a.BID, to_char(a.EFF_START_TS,'dd-mm-yyyy hh:mi:ss'), a.NETWORK_AREA_PROV_STATE_CD, a.NETWORK_AREA_CITY_NM, a.SWITCH_ID, a.CREATE_USER_ID,a.LAST_UPDT_USER_ID, to_char(a.CREATE_TS,'dd-mm-yyyy hh:mi:ss'), to_char(a.LAST_UPDT_TS,'dd-mm-yyyy hh:mi:ss')
-
from HORATIU_NETWORK_AREA a,
-
(
-
select hna1.CELL_ID, hna1.LAC_ID, count(*) from
-
HORATIU_NETWORK_AREA hna1
-
-
group by hna1.CELL_ID,hna1.LAC_ID having count(*)>1) b
-
where
-
a.cell_id = b.cell_id and
-
a.lac_id=b.lac_id and
-
a.eff_stop_ts >= to_date('01-01-9999 00:00:00', 'dd-mm-yyyy hh24:mi:ss')
-
order by a.cell_id, a.lac_id
-
) c
-
where
-
c.cell_id = d.cell_id and
-
c.lac_id = c.lac_id
-
.lac_id=d.lac_id
-
0 1551 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Don |
last post by:
Hi,
I am moving from Sybase to Oracle and I used to be able to do update
statement like this in Sybase:
UPDATE TABLE1
SET T1.field1 = T2.field2
FROM TABLE1 T1, TABLE2 T2
WHERE T1.field2...
|
by: red85 |
last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an
alpha and i don't know if someone else has already posted this
problem:
when i execute this sql
UPDATE tableX SET...
|
by: sqlgoogle |
last post by:
Hi I'm trying to update a db based on the select statement which has
ORDER BY in it.
And due to that I'm getting error which states that
Server: Msg 1033, Level 15, State 1, Line 13
The ORDER...
|
by: kalamos |
last post by:
This statement fails
update ded_temp a
set a.balance = (select sum(b.ln_amt)
from ded_temp b
where a.cust_no = b.cust_no
and a.ded_type_cd = b.ded_type_cd
and a.chk_no = b.chk_no
group by...
|
by: serge |
last post by:
/*
This is a long post. You can paste the whole message
in the SQL Query Analyzer.
I have a scenario where there are records
with values pointing to wrong records and I need to fix them
using an...
|
by: robert |
last post by:
i need to update a column which is a member of the PK on this
table. there are some thousands of rows to be updated, many more
thousand already in the table.
so, i get a constraint violation...
|
by: Dave Smithz |
last post by:
Hi there,
Been working on an evolving DB program for a while now. Suddenly I have come
across a situation where I need to update a table based on a group by query.
For example, I have a table...
|
by: P3Eddie |
last post by:
Hello all!
I don't know if this can even be done, but I'm sure you will either help or suggest another avenue to accomplish the same.
My problem may be a simple find duplicates / do something...
|
by: Bogdan |
last post by:
Hi,
I have a stored procedure that uses JOINs to return columns from multiple
tables. I also have another stored proc that that takes a series of params
and updates multiple tables. I used the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
| |