为什么累计求和时会自动变为整数
有一数据表,类型如下table1:
aa char(3),
jine decimal(14,2),
flag char(1)
想对其中的数据进行分类汇总,
select aa,sum(jine) ssje,0 qdje,0 pkje
from table1
where flag='2'
into temp tmpbd;
insert into tmpbd
select aa,0 ssje,sum(jine) qdje,0 pkje
from table1
where flag='1';
insert into tmpbd
select aa,0 ssje,0 qdje,sum(jine) pkje
from table1
where flag='3';
汇总
select aa,sum(ssje),sum(qdje),sum(pkje)
from tmpbd
group by 1
为什么合计出来了金额都是整理,没有小数呢?该如何做呢?多谢了 用sum(ssje)::dec试试!
页:
[1]