如何从表中减去当前年份。
我有一个包含列VehicleYear
的表格。因此,我只需从VehicleYear
中减去当前年份即可获得VehicleAge
。
我尝试了以下查询,但由于SYSDATE
似乎反映了添加行的日期,因此无效。
SELECT V. VEHICLENAME, (SYSDATE - V.VEHICLEYEAR) AS CURRENTAGE
FROM VEHICLE V
答案 0 :(得分:1)
您可以运行此查询以从两个日期中减去年份
SELECT VEHICLENAME,
EXTRACT(YEAR FROM sysdate) - EXTRACT(YEAR FROM VehicleYear) AS CURRENTAGE
FROM VEHICLE;