第一条sql语句和第二条的执行结果应该是一模一样的!如果只是第一条语句不合要求,每天多过一条记录的话,我还能猜测是因为docdate中包含了时间字段,同一天中有多个时间不同的值,那样用trunc()函数过滤掉时间值就可以了。如下:
select trunc(docdate) docdate,sum(area) area,sum(value) value
from test1 a,test2 b,test3 c
where a.id=b.id
and a.id=c.id
and b.type1='a'
and c.type2='b'
group by trunc(docdate);但是无论如何想不通为什么同样的情况下第二条可以,奇怪之极!
select trunc(docdate) docdate,sum(area) area,sum(value) value
from test1 a,test2 b,test3 c
where a.id=b.id
and a.id=c.id
and b.type1='a'
and c.type2='b'
group by trunc(docdate);但是无论如何想不通为什么同样的情况下第二条可以,奇怪之极!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货