select a.USERCODE,a.USERNAME,a.RUNCAP,sum(P_VAL)
from USER a,P_TOTAL b,TOTAL_DAY_STAT
where a.USERCODE=b.USERCODE
and b.TOTALCODE=c.TOTALCODE
and to_char(c.D_DATE,'yyyymmdd')='20130308'
and a.RUNCAP>1000
group by a.USERCODE,a.USERNAME,a.RUNCAP
是这个意思吗?
select usercode,username,runcap,p_val
from user u,p_total p,total_day_stat t
where u.usercode=p.usercode and p.totalcode=t.totalcode
and d_date='2013-03-08'
and u.runcap>1000
SELECT U.USERCODE, U.USERNAME, U.RUNCAP, T.P_VAL
FROM USER U INNER JOIN P_TOTAL P ON U.USERCODE = P.USERCODE
INNER JOIN P.TOTALCODE = T.TOTALCODE
WHERE U.RUNCAP > 1000 AND T.D_DATE = '2013-03-08'
按照题的意思应该是想查出8号有数且用户容量大于1000的用户,但是最后的有功电量加在查询结果的最后有点怪。