50分!!sql查询
select
count(1) as '北京'
, sum(TFT_TRNAMT) as 金额
,left( TFT_DTE ,6) as month
from ABST_TrnFlw group by left( TFT_DTE ,6)
order by month
select sum(TFT_TRNAMT) as 分发金额
,left( TFT_DTE ,6) as month
from ABST_TrnFlw where TFT_TRNFIG='1'
group by left( TFT_DTE ,6)
现在把2个表格利用 month 左连接,
谢谢 帮忙拼起来。
[解决办法]
select * from
(select
count(1) as '北京'
, sum(TFT_TRNAMT) as 金额
,left( TFT_DTE ,6) as month
from ABST_TrnFlw group by left( TFT_DTE ,6)
order by month ) a1
left join
(select sum(TFT_TRNAMT) as 分发金额
,left( TFT_DTE ,6) as month
from ABST_TrnFlw where TFT_TRNFIG='1'
group by left( TFT_DTE ,6)) a2
on a1.month=a2.month
[解决办法]
select *from (select count(1) as '北京', sum(TFT_TRNAMT) as 金额 ,left( TFT_DTE ,6) as month from ABST_TrnFlw group by left( TFT_DTE ,6)) a left join (select sum(TFT_TRNAMT) as 分发金额,left( TFT_DTE ,6) as month from ABST_TrnFlw where TFT_TRNFIG='1' group by left( TFT_DTE ,6)) b on a.month=b.month