DECLARE
eno integer := 0;
emp string ;
select into eno emp_no from "public"."salaries" GROUP BY emp_no ORDER BY max(salary) DESC LIMIT 1;
-- gives the emp_no of the employee with maximim salary
select INTO emp CONCAT(first_name, ' ' , last_name) as "Name" from "employees"
WHERE emp_no = eno;
-- gives the name of the employee with the emp_no from preveous result
raise NOTICE "The Employe with maximum salary is %",emp;
错误消息:错误:“整数”处或附近的语法错误
我试图获得最高薪水的 emp 名称 请帮忙
您需要将声明与值的初始化分开。
这样做:
DECLARE
eno integer;
BEGIN
eno := 0;
... rest of your code here
END;