我的表結構增加派生列是這樣的:比較兩個日期列和使用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