1
我有一個WHONET_ORGANISMOS列與ORG列,並且此列提供了一些重複的值。計算重複值
ORG 弧 ACK ABC ABC
我想在reapeted那些年底assing連續值。
而且我希望它變成這個樣子
ORG 弧 ACK ABC ABC1
我想這個查詢,但不工作,你能幫幫我嗎?
DECLARE @conta INT
DECLARE @conta2 INT
SET @conta = 1
SET @conta2 = 1
WHILE (@conta>=1)
BEGIN
UPDATE WHONET_ORGANISMOS
SET ORG = {fn concat (ORG, @conta2)}
WHERE ID IN
(
SELECT MAX(ID)
FROM WHONET_ORGANISMOS
GROUP BY ORG
HAVING count(*) > 1
);
SET @conta2 = @conta2 +1;
SET @conta = SELECT COUNT(*)(SELECT ORG, COUNT(*) TotalCount FROM WHONET_ORGANISMOS GROUP BY ORG HAVING COUNT(*) > 1)
END
GO