计算平均率之间的差异

时间:2014-11-17 13:02:46

标签: oracle

我需要找到过去12个月内staff表和非staff表的平均费率之间的差异。

这是我到目前为止所做的:

select  person.pid, 
        person.firstname, 
        person.lastname,
        AVG(RATING_RECORD.RATE)
from person, 
     client, 
     staff, 
     policy,
     COVERAGE,
     RATING_RECORD
where person.PID = client.PID  and  
      staff.pid = person.pid and 
      policy.SID =staff.SID and 
      COVERAGE.PNO = policy.PNO and
      COVERAGE.COID = RATING_RECORD.COID;

现在我来到了这个

select  person.pid,
    person.FIRSTNAME,
    AVG(RATING_RECORD.RATE)
from person 
    join client on person.pid = client.pid 
    join staff on person.pid = staff.pid  
    join policy on staff.sid = policy.sid
    join coverage on policy.PNO = coverage.PNO
    join RATING_RECORD on coverage.COID = RATING_RECORD.COID
where policy.EXPIRYDATE between '12-NOV-13' and '12-nov-14 '
group by person.PID, person.FIRSTNAME;

但问题是它只显示3个结果而不是整个列表?

我想出了这个评论,我把客户加入了,然后提出来了 13结果

select  person.pid,
person.FIRSTNAME,
AVG(RATING_RECORD.RATE)
from person 

join staff on person.pid = staff.pid  
join policy on staff.sid = policy.sid
join coverage on policy.PNO = coverage.PNO
join RATING_RECORD on coverage.COID = RATING_RECORD.COID

where policy.EXPIRYDATE between '12-NOV-13' and '12-nov-14 '
group by person.PID, person.FIRSTNAME;

但我如何让客户回来给我的员工和非员工?

0 个答案:

没有答案