MySQL compute percent change I am new in MySQL.. I want to compute for the percent change of this table using MySQL. Can you help me with the script? I am using 10.3.8-MariaDB MariaDB Server.. Thanks..

CREATE TABLE `MyTable` (
  `Column` VARCHAR(14),
  `Amount` VARCHAR(6);

INSERT INTO `MyTable` (`Column`, `Amount`) 
VALUES (`Column 1`, `500`),(`Column 2`, `100`),(`Column 3`, `1100`);


I want to get an output table sorted by Column:

Column   | Amount | Previous Amount         | Percent Change
Column 1 | 500    | 0                       | ((500-0)/0)*100
Column 2 | 100    | 500 (amount in column1) | ((100-500)/500)*100
Column 3 | 1100   | 100 (amount in column2) | ((1100-100)/100)*100
SELECT `Column`,
       Amount,
       COALESCE(LAG(Amount) OVER (ORDER BY `Column` ASC), 0) `Previous Amount`,
       COALESCE(100*(Amount -
                 LAG(Amount) OVER (ORDER BY `Column` ASC)) /
                 LAG(Amount) OVER (ORDER BY `Column` ASC), 0) `Percent Change`
FROM MyTable ;


fiddle

PS. It's extremely bad practice to store number data in VARCHAR field.

PPS. While using any ticks always look for a proper tick type.