Hello everyone,
Here I am trying to do the multiplication of reach row multiplied by different values.
For example..,
I have 3 columns with customer_id(int), product_name(varchar) , price(int)
Now, In the column of Product_name = LV, MK, Price column should be multiplied by 10 (Price * 10) and Product_name = YSL product Price column should be multiplied by 20 (Price * 20). Display the results as a new columns as points achieved by each customer.
Could you please tell me how can I achieve this..,
Your help could be appreciated
>Solution :
You can get it done by incorporating a CASE statement directly in the SQL.
SELECT
customer_id,
product_name,
CASE
WHEN product_name IN ('LV', 'MK') THEN price * 10
WHEN product_name = 'YSL' THEN price * 20
ELSE price
END as adjusted_price
FROM TABLENAME;