我的表像需要編寫子查詢來計算收入每月
summa_som date_operation
----- --------------
100 11/03/2005
500 13/07/2008
900 12/11/2015
預期結果
我要計算每月的收入應該有3列: 收入,月和年:
Income Month Year
------ -------- ----
10000 February 2015
15000 December 2015
我試過這個,但是,我不明白子查詢是如何工作的。此代碼應該給我想要的東西的想法:
select max(summa_som * 0.01) income
from t_operation
where to_char(date_operation,'MM') = 11
and to_char(date_operation,'YYYY') = 2015
(select max(summa_som * 0.01) income_for_dec2015 from t_operation
where to_char(date_operation,'MM') = 12
and to_char(date_operation,'YYYY') = 2015)
非常感謝 – vesperkg