当字段类型为 unsigned 时,使用相关结果为负值时就会报错,报错如下:

BIGINT UNSIGNED value is out of range in ..


解决方法


使用 cast() 修改字段类型为 signed

select cast(quantity as signed) - cast(frozen_quantity as signed) from ...