计算第一个月到最后一个月的总和
calculate total sum from first month to the last month
如何计算第一个月到最后一个月的总和值?
示例:
这是我试过的方法,但它没有像上面的示例那样显示输出。
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)
有没有可能得到这样的结果?提前致谢。
就用这个:
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)
如何计算第一个月到最后一个月的总和值?
示例:
这是我试过的方法,但它没有像上面的示例那样显示输出。
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)
有没有可能得到这样的结果?提前致谢。
就用这个:
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)