select a.userid,sum(d.colname)totalvalue from a,b,c,d where a.userid=b.userid and b.measid=c.measid and c.meterid=d.meterid group by a.userid 由于都是一对多关系,可以这么写
select a.userid,sum(d.totalvalue) from a,b,c,d where a.userid=b.measid and b.measid=c.meterid and c.meterid=d.recid group by a.userid;
from a,b,c,d
where a.userid=b.userid
and b.measid=c.measid
and c.meterid=d.meterid
group by a.userid
由于都是一对多关系,可以这么写
where a.userid=b.measid and b.measid=c.meterid and c.meterid=d.recid
group by a.userid;