我的表结构增加派生列是这样的:比较两个日期列和使用Oracle SQL
ID,
country,
month,
year,
total amt in previous period,
total amt during period,
incr/decr in total amt in previous period,
incr/decr in total amt during (month, year)
的ID
,month
,year
和total amt
域在表abc
可用。 incr/decr in total amt in previous period
是total amt in previous period
和total amt during period
列之间的差异。
我写此查询:
select m.id, m.month, m.year, m.total_amt
from abc m
order by year, month desc;
对于total amt in previous period
我不能使用Between Date() And DateAdd("M", -1, Date());
,因为我没有约会,但只是年份和月份。
如何比较两列与year
和month
列以及如何使用子查询具有最后两个派生列?
你是表结构对我来说并不明确。 – moffeltje 2015-03-31 10:11:05
期间的总金额与月和年相比,并返回当前月份和年度(2015年3月)中“总金额”的值,前一期间的总金额与当月的前一个月(2015年2月)相比较并显示值 – k1j 2015-03-31 10:22:01