Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name
group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message: Error 1415 (0A000) :Not allowed to return a result set from a function

Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name
group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message: Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name
group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message:

Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

added 4 characters in body
Source Link
A T
  • 3
  • 3

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

 create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
 begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message: Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

 create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
 begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message: Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

 create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
 begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message: Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

Source Link
A T
  • 3
  • 3

Create function with mysql

Hello I have an assignment: Consider an employee database with two relations:

employee(employee-name, street, city)
works(employee-name, company-name, salary)

where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at "First Bank Corporation". Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given company. I created this function:

 create function avg_salary (c_name varchar(30))
 returns numeric(8,6)
 begin
 declare a_salary numeric(8,6);
 select avg(salary) into a_salary from works where company.company_name = c_name group by company_name; 
 return a_salary; 
 select company_name from works where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end

But I get an error message: Error 1415 (0A000) :Not allowed to return a result set from a function

I don't understand why I get this error. Thank you for your help

lang-sql

AltStyle によって変換されたページ (->オリジナル) /