Reputation: 113
I have two tables. One is the Source table and the other is the Master. I need to do an update if the matched item and the change price in the Source table is an increase of no more than 10% of the Master table.
WHEN MATCHED AND (Source.list_price - Master.list_price)/100 < .10
UPDATE SET...
This can work but there are some prices in the Source table that's lesser than the Master table. How do I make sure that the query is only to action if it's an increase?
Upvotes: 0
Views: 29
Reputation: 21757
Add in a condition to check that Source
price is greater than the price in Master
table like so:
WHEN MATCHED AND (Source.list_price - Master.list_price)/100 < .10 AND Source.list_price > Master.list_price
UPDATE SET...
Upvotes: 1