Add a conditional CHECK using two columns
SQL
Medium
5 views
Problem Description
In Coupons(code, discount_percent, max_discount), discount_percent must be 0 to 80, and max_discount must be at least 100 if discount_percent > 50.
Output Format
DDL statement(s)
Sample Test Case
Input:
Coupons(code, discount_percent, max_discount)
Constraints
Assume table exists
Official Solution
ALTER TABLE Coupons ADD CONSTRAINT chk_coupon_rules CHECK (discount_percent BETWEEN 0 AND 80 AND (discount_percent <= 50 OR max_discount >= 100));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!