Find : max - min / min * 100
SELECT
*,
MAX(Salary),
MIN(Salary),
MAX(Salary) - MIN(Salary)
FROM
Salary
GROUP BY
empid
How to perform /
operation ?
SELECT
*,
MAX(Salary),
MIN(Salary),
((MAX(Salary) - MIN(Salary)) / MIN(Salary))
FROM
Salary
GROUP BY
empid
This is showing zero zero
1条答案
按热度按时间mxg2im7a1#
I got the zeroes when trying your query in SQLite3 when I declared the Salary as
INTEGER
. You haven't shown the declaration of the table, though, so it's just a guess.What helped was to cast the divisor as real:
But if you need to result multiplied by 100, you can just multiply the subtraction before doing the division: