我在查找有关此案例的适当查询时遇到问题。
表格预订
表CUSTOMER
问题是如果客户有超过10个状态为1的预留行,我找不到设置VIP = true的方法。所有使用ansi sql。
你可以帮我一把吗?答案 0 :(得分:2)
是的,试试这个:
Update CUSTOMER Set VIP = 1
Where (Select Count(*) From RESERVATION
Where CustomerId = CUSTOMER.CustomerId
And Status = 1) > 10
或
Update c Set VIP = 1
From Customer c
Where (Select Count(*) From RESERVATION
Where CustomerId = c.CustomerId
And Status = 1) > 10