我有一个包含重复和唯一 ID 的表。我想在所有交易费用中添加 10 美分,在重复的第一行订单中添加 10 美分,例如:
What i start with:
order# Fee
123 5
123 4
111 3
122 5
what I should get:
order# Fee
123 5.1 --duplicates
123 4.0 --should not have 10 cents.
111 3.1
122 5.1
我尝试使用下面的代码,但它会更新每个订单#
-- updates table adds 10 cents to the first order of each duplicate and every unique order
update ebaytemp
set [transaction fees] = [transaction fees] +.10
from (SELECT [order#]
from ebaytemp
GROUP BY order#
HAVING COUNT(order#) > 1) as E