【发布时间】:2017-05-28 22:37:10
【问题描述】:
我正在使用 SQLite,并试图弄清楚如何为记录了超过 3 次购买的客户提供折扣。我尝试了以下方法,但它仅按退货更新 customer_ID 组第一行的折扣。
update orders
set discount = price*0.5
where customer_ID = (
select customer_ID from orders
group by customer_ID
having count(customer_ID) > 3
);
如何实现上述预期结果?
【问题讨论】:
-
where customer_ID IN(...)可能会有所帮助 -
如果您的子查询准确返回正确客户的 ID,应该没问题。
-
你太棒了,谢谢!