我正在尝试使用for循环打印一组数据,并且很好奇是否可以使用别名来检索信息,或者我将如何为for循环使用
DECLARE
job_ VARCHAR2(35);
employee_name VARCHAR2(35);
manager_name VARCHAR2(35);
salary_difference NUMBER(20,2);
CURSOR cur_salary_difference IS
SELECT job_title, employees.first_name || ' ' || employees.last_name "Employee",
m.first_name || ' ' || m.last_name "Manager", (employees.salary-m.salary) "Salary Difference"
FROM employees
LEFT OUTER JOIN employees m ON
employees.manager_id = m.employee_id
JOIN jobs j ON employees.job_id = j.job_id
ORDER BY "Employee";
BEGIN
DBMS_OUTPUT.PUT_LINE('Listings of employees with salary difference compared to manager');
FOR people IN cur_salary_difference LOOP
DBMS_OUTPUT.PUT_LINE (chr(10) || 'Job Title:' || people.job_title);
DBMS_OUTPUT.PUT_LINE ('Employee:' || people.employee);
DBMS_OUTPUT.PUT_LINE ('Manager:' || people.manager);
DBMS_OUTPUT.PUT_LINE ('Salary Difference:' || salary_difference);
END LOOP;
END;
答案 0 :(得分:2)
答案 1 :(得分:1)
应该可以,只要解决薪水上的错字
(employees.salary-m.salary) "Salary_Difference"