Have a table with ID, IDLicense, Brand, and ExtraBrands
Trying to grab all like records by an IDLicense combined all records by taking all copies of IDLicense deleting all copies but taking the brand name and adding it to the original IDLicense and adding the brand of the deleted copy to the ExtraBrands.
So far I have been able to select all IDLicense that have duplicates. Using a temp table to store all extra info.
INSERT INTO #TempTable (ID, IDLicense, Brand, ExtraBrands)
SELECT ID, IDLicense, Brand, ExtraBrands FROM BrandOrders
WHERE IDLicense IN (SELECT IDLicense FROM BrandOrders GROUP BY IDLicense HAVING COUNT(*) > 1)
is a simple way to instead of using a temp table here to instead just delete all like data and take brands from copies and add them as ExtraBrands? Afterwards deleting the duplicates.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire