可以在select语句周围编写触发器吗?

时间:2013-11-01 14:08:36

标签: mysql

可以在此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;

如果是,建议将不胜感激

0 个答案:

没有答案