Simple SQL to update Mana usage
#2

Yess! really nice statement. Only improvement I have is to include comments and use the "between" Like:



UPDATE t_skilllevel

SET a_needMP = CASE

    -- Decrease by 30% for values between 500 and 750

    WHEN a_needMP BETWEEN 500 AND 750 THEN a_needMP * 0.70

    -- Decrease by 50% for values between 751 and 1000

    WHEN a_needMP BETWEEN 751 AND 1000 THEN a_needMP * 0.50

    -- Decrease by 65% for values between 1001 and 1500

    WHEN a_needMP BETWEEN 1001 AND 1500 THEN a_needMP * 0.35

    -- Decrease by 75% for values between 1501 and 2000

    WHEN a_needMP BETWEEN 1501 AND 2000 THEN a_needMP * 0.25

    -- Decrease by 83% for values between 2001 and 3000

    WHEN a_needMP BETWEEN 2001 AND 3000 THEN a_needMP * 0.17

    -- Decrease by 97% for values greater than 3000

    WHEN a_needMP > 3000 THEN a_needMP * 0.03

    -- No change for other values

    ELSE a_needMP

END;



Basically just explains the logic for the rages. Easier to understand and the use of "between" makes it a bit more readable if you ask me. 



Please correct me if I'm wrong! 



Messages In This Thread
[No subject] - by Judgement - 11-20-2023, 02:15 AM
[No subject] - by RGT - 11-25-2023, 01:29 AM
[No subject] - by Scura - 11-29-2023, 09:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)