Count in an Update statement - How do you do it

I have a select statement with a count that works just fine.
But when I add the update statement I get en error stating that my count field is an invalid identifier

–Update the Follow Up Cnt field
Update schuck1.seibel_contacts@cepd.devl.corp.cname.com
Set follow_up_cnt = acnt where acnt in
(select mdm2.mdm_cust_id, s_cont_id, count(ACON.RELATION_TYPE_CD) acnt
from sds_ifo_s_contact scon,
sds_ifo_s_asset_con acon,
( Select *
from sds_ifo_s_asset
where type_cd = ‘Device Set’
and status_cd = ‘Active’) asset,
schuck1.seibel_contacts@cepd.devl.corp.cname.com MDM2
where scon.row_id = mdm2.s_cont_id
and scon.row_id = acon.contact_id
and acon.asset_id = asset.row_id
Group by mdm2.mdm_cust_id, s_cont_id
)
;

Commit;

Kimberly Schuck
Prin IT Bus Systems Analyst
Global Master Data and Integration

[CONFIDENTIALITY AND PRIVACY NOTICE]

Information transmitted by this email is proprietary to Medtronic and is intended for use only by the individual or entity to which it is addressed, and may contain information that is private, privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please delete this mail from your records.

To view this notice in other languages you can either select the following link or manually copy and paste the link into the address bar of a web browser: http://emaildisclaimer.medtronic.com

Morning Kimberly,

On 24/01/11 19:05, Schuck, Kimberly wrote:

...
Set follow_up_cnt = acnt where acnt in
(select mdm2.mdm_cust_id, s_cont_id, count(ACON.RELATION_TYPE_CD) acnt

You appear to be asking Oracle to compare acnt with (mdm_cust_id,
s_cont_id, acnt) - in other words your IN has three columns but you are
comparing it with one.

I suspect you might get away with it by :

Set follow_up_cnt = acnt where acnt in
(select acnt from
(select mdm2.mdm_cust_id, s_cont_id, count(ACON.RELATION_TYPE_CD) acnt
...)
)

In other words, extracting the acnt column from the inline.

However, don't quote me as it's early AM and my first coffee has not had
time to energise my system. :wink:

Alternatively, you can do this (sometimes) :

update (select statement)
Set whatever = something,
whatever_else = somethihng_else
where ....;

Resulting in something like:

Update

(select mdm2.mdm_cust_id, s_cont_id, count(ACON.RELATION_TYPE_CD) acnt
from sds_ifo_s_contact scon,
sds_ifo_s_asset_con acon,
( Select *
from sds_ifo_s_asset
where type_cd = 'Device Set'
and status_cd = 'Active') asset,
schuck1.seibel_contacts@cepd.devl.corp.cname.com MDM2
where scon.row_id = mdm2.s_cont_id
and scon.row_id = acon.contact_id
and acon.asset_id = asset.row_id
Group by mdm2.mdm_cust_id, s_cont_id
)

Set follow_up_cnt = acnt where acnt in (list of acnts to be updated);

--
Cheers,
Norm. [TeamT]

Or in the alternative, if you need to compare all three fields, you could use
the structure:

Select *

From dual

Where (1,2,3) in (select 1,2,3 from dual);

Roger S.