I have two tables where I need to update from one into the other . The table I am updating contains account numbers which is the primary key.
The table I am getting the data from also has an account number that ties to the first table. The field I need however can contain two values for every Account number.
So in short I need to flatten out this data into my main table.
I have tried this in an update statement as follows:
update B
set CIS_NUM1 = MIN(C.APP_ID), CIS_NUM2 = MAX(C.APPL_ID)
FROM BUSCARDS_WKLY B JOIN CIS_LINK C
ON B.ACCT_NUM = C.APPL_ID
However this gives me the following:
An aggregate may not appear in the set list of an UPDATE statement.
How can I update the first occurance of the appl_id into the CIS_Num1 field and the second occurance into the CIS_Num2 field.
Thanks.
The table I am getting the data from also has an account number that ties to the first table. The field I need however can contain two values for every Account number.
So in short I need to flatten out this data into my main table.
I have tried this in an update statement as follows:
update B
set CIS_NUM1 = MIN(C.APP_ID), CIS_NUM2 = MAX(C.APPL_ID)
FROM BUSCARDS_WKLY B JOIN CIS_LINK C
ON B.ACCT_NUM = C.APPL_ID
However this gives me the following:
An aggregate may not appear in the set list of an UPDATE statement.
How can I update the first occurance of the appl_id into the CIS_Num1 field and the second occurance into the CIS_Num2 field.
Thanks.