query correction required [message #643436] |
Wed, 07 October 2015 09:05 |
|
amy.wilson
Messages: 39 Registered: September 2015 Location: Www
|
Member |
|
|
Hi All,
I have written a query to update a column..
update urole set unmatched_records= (select concat(regname,ID) from urole where rcount>1) where unmatched_data is null;
I have data as follows
ID DNAME REGNAME RCOUNT Unmatched_Data
--------------------------------------------------------
1 Agency Agency 1 <Null>
2 Eastern Atlanta 1
3 Eastern Boston 1
4 Business Business 1
5 Canada Canada 2
6 Eastern Canada 2
7 Central Central 1
8 Central Central Region1
9 Central Chicago 1
10 Central Cincinnati 1
11 Marketing Marketing 1
12 Media Media 1
13 Media Media Eastern 1
14 Media Media Western 1
15 Custom Pub Custom Pub 2
16 Eastern Custom Pub 2
Here unmatched_data column is null.
so I would like to write a query to update UNMATCHED_DATA column by concatenating REGNAME and ID columns where REGCOUNT>1
Can you have a look and advise me a query.
Thanks
|
|
|
Re: query correction required [message #643440 is a reply to message #643436] |
Wed, 07 October 2015 09:36 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
It's not all obvious what the expected result is.
either it's this:
update urole set unmatched_records= concat(regname,ID) where unmatched_data is null and rcount>1;
Or you need to explain which records should be used to update which other records.
|
|
|
|
|
|
Re: query correction required [message #643459 is a reply to message #643453] |
Wed, 07 October 2015 23:21 |
|
Michel Cadot
Messages: 68641 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
In addition, With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
|
|
|