Lat
Lat

Reputation: 35

two decimal places in MySQL but it shows error at the word SELECT

hi can anyone help me on how to execute the "NEW-BONUS" column with two decimal places? i tried cast, round, truncate and decimal but it shows error at the word SELECT

SELECT LASTNAME, EDLEVEL,
SALARY+1200 AS "NEW-SALARY",
BONUS*0.5 AS "NEW-BONUS"
FROM EMPLOYEE
WHERE EDLEVEL = 18 OR EDLEVEL = 20
ORDER BY EDLEVEL DESC, 3

Upvotes: 1

Views: 64

Answers (1)

Shafiqul Islam
Shafiqul Islam

Reputation: 5690

You can try using "TRUNCATE"

So please update your query like this

SELECT LASTNAME, EDLEVEL,
(123+1200) AS "NEW-SALARY",
TRUNCATE((111*0.5),2) AS "NEW-BONUS"
FROM EMPLOYEE
WHERE EDLEVEL = 18 OR EDLEVEL = 20
ORDER BY EDLEVEL DESC, 3

123 is demo value and 111 is also demo value

Upvotes: 1

Related Questions