1

我正在使用 Oracle APEX,我对如何制作它的查询有点困惑。我创建了两个具有以下属性的表

Employees(  "EMP_ID", 
    "EMP_NAME", 
    "EMP_DESIGNATION" , 
    "EMP_ADDRESS" , 
    "EMP_GENDER", 
    "EMP_CONTACT", 
    "EMP_EMAIL" , 
    "EMP_JOINING_DATE", 
     CONSTRAINT "PK_EMP_ID" PRIMARY KEY ("EMP_ID") ENABLE
   );`

Attendance
(   ATT_ID, 
    EMP_ID, 
    ATT_STATUS, 
    ATT_IN DATE, 
    ATT_OUT DATE, 
    ATT_COMMENTS, 
CONSTRAINT "PK_ATT_ID" PRIMARY KEY ("ATT_ID") ENABLE
CONSTRAINT "FK_EMP_ID" FOREIGN KEY ("EMP_ID") REFERENCES "EMPLOYEES" ("EMP_ID"));

我已经减去了Att_OutAtt_In得到的时间(以分钟为单位),然后multiply.69是员工每分钟的工资,如查询图所示。

select emp_id,sum(((att_out-att_in)*1440)*.69) as "minutes*sal/m" 
from attendance group by emp_id;

在此处输入图像描述

如上所述,我想select EMP_ID,EMP_NAME从表中提取其余查询。Employees我做了,INNER JOIN但后来group by功能给了我错误。

4

4 回答 4

1

试试这个

SELECT e.emplid, e.emp_name,  
sum(((a.att_out-a.att_in)*1440)*.69) as "minutes*sal/m"
FROM Employees e 
inner join attendance a on e.emplid = a.emplid
group by e.emplid, e.emp_name
于 2013-02-13T05:45:10.343 回答
0

尝试以下查询

select emp_id,sum(((att_out-att_in)*1440)*.69) as "minutes*sal/m" from attendance a,employees e 
where e.emp_id=a.emp_id
group by emp_id;
于 2013-02-13T05:47:28.040 回答
0
SELECT e.emp_id, e.emp_name, sum(((a.att_out-a.att_in)*1440)*.69) as "minutes*sal/m" 
FROM Employees e 
inner join attendance a on e.emp_id = a.emp_id 
group by e.emp_id, e.emp_name;
于 2013-02-13T05:49:43.620 回答
0

这可能对您有帮助:

SELECT e.emplid, e.emp_name,  
sum(((a.att_out-a.att_in)*1440)*.69) as  employees_salary_per_minute
FROM Employees e 
inner join attendance a on e.emplid = a.emplid
group by e.emplid, e.emp_name
于 2013-02-14T11:21:08.407 回答