How to calculate total sum value from first month to the last?
Example:
This is what I've tried, but it doesn't showing the output like the example above.
select
left(convert(varchar,txd.OPERATIONALDATE,112),6) MONTH,
sum(AMOUNTVALUE) TOTAL_A,
sum(10*AMOUNTVALUE) TOTAL_B,
sum(10*AMOUNTVALUE) + sum(10*AMOUNTVALUE) TOTAL_C
from tx_details txd
inner join TX_SELISIH txs
on txd.TXID=txs.TXID
and txd.OFFICEID=txs.OFFICEID
where txd.operationaldate BETWEEN '20200101' AND '20201231'
and TXDATE>'20190831'
and SELISIHTYPE=1
GROUP BY left(convert(varchar,txd.OPERATIONALDATE,112),6)
Is it even possible to get the result like that? Thanks in advance.
Just use this:
SELECT
left(convert(varchar,txd.OPERATIONALDATE,112),6) MONTH,
sum(AMOUNTVALUE) TOTAL_A,
sum(10*AMOUNTVALUE) TOTAL_B,
SUM ( Sum(10*AMOUNTVALUE) + sum(10*AMOUNTVALUE) ) OVER ( ORDER BY left(convert(varchar,txd.OPERATIONALDATE,112),6) ) TOTAL_C
from tx_details txd
inner join TX_SELISIH txs
on txd.TXID=txs.TXID
and txd.OFFICEID=txs.OFFICEID
where txd.operationaldate BETWEEN '20200101' AND '20201231'
and TXDATE>'20190831'
and SELISIHTYPE=1
GROUP BY left(convert(varchar,txd.OPERATIONALDATE,112),6)