Hi all... Im having a problem with my scripts, am trying to update a field in a table, which takes count from another table.. This returns more than 1 value. The problem is that there is no unique column in the table from which Im updating the other table. Below is my code: Can someone plz help me out here? Thanks.
In STG_CNVF there's no unique column as such..
UPDATE [dbo].[DMF_ACTUAL_SALES]SET NVF=
(
SELECT COUNT(BOUQUET_OPTION_ID)
FROM [dbo].[STG_CNVF] B
WHERE B.DATE_VALIDATED IS NULL
OR B.NO_OF_DAYS>7
GROUP BY B.SALESREP_ID, B.DISTRIBUTORS_ID,B.BOUQUET_OPTION_ID,DATE_ID,NO_OF_DAYS,NO_OF_SALES
)
FROM [dbo].[DMF_ACTUAL_SALES] A,[dbo].[STG_CNVF] B
WHERE A.SALESREP_ID=B.SALESREP_ID
AND A.BOUQUET_OPTION_ID=B.BOUQUET_OPTION_ID
AND A.DISTRIBUTORS_ID=B.DISTRIBUTORS_ID
AND A.MONTH_ID=CONVERT(VARCHAR(6),B.DATE_ID,112)