how to multiply columns that have dollar signs in them with numbers???

I have a table with salary amount that I want to multiply with .08 but when I run my SQL query, It returns a 0 zero values. Because there is a dollar sign in every row in my Column salary.

SELECT SALARY * .08 AS INCOME_TAX FROM table_name;

It works on my other tables that don't have the dollar sign in the rows.

But I think the dollar sign is causing a issue and displaying Zero,

Anyone know how to execute a SQL query so that I can multiply .08 and display the values.

thanks in advance :)

Answer Answered by Ian Gilfillan in this comment.

Sounds like you're storing the salary as a string with a dollar sign. This needs to be stripped out, so, if the dollar sign is always the first character, something like SELECT SUBSTRING(SALARY,2) * .08 AS INCOME_TAX FROM table_name; should be what you're looking for.

See the SUBSTRING() and CAST() pages for more on those functions.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.