Home > Back-end >  Creating a column from another column with a 3% increase SQL
Creating a column from another column with a 3% increase SQL

Time:10-26

I have a table named QUOTATIONS and a column named price. I am trying to create a new column named NEW_PRICE that is all the data from PRICE with a 3% increase. So far I have been unsuccessful at even adding the new column with:

ALTER TABLE QUOTATIONS
ADD COLUMN  NPRICE NUMBER(4);

CodePudding user response:

Use a generated column:

ALTER TABLE QUOTATIONS
ADD COLUMN  NPRICE NUMBER(4) AS PRICE * 1.03;
  • Related