可以在此MySQL代码上应用触发器吗?
SELECT name, cost AS originalCost, whenacquired, monthsDepreciated, monthlyDepreciation,
monthsDepreciated * monthlyDepreciation AS totalDepreciation,
cost - monthsDepreciated * monthlyDepreciation AS depreciatedValue
FROM (
SELECT name,
cost,
whenacquired,
(YEAR(NOW())*12 + Month(NOW())) - ( YEAR(whenacquired)*12 + Month(whenacquired)) AS monthsDepreciated,
cost / ( life * 12 ) AS monthlyDepreciation
FROM assets
) AS X
ORDER BY whenacquired;
如果是,建议将不胜感激