🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

Stored procedures – Example – Part II

Stored procedures – Example – Part II

Super Learner

As the question was asking about finding the average salary, does this query work as well? I thought that we had to take into account the repeats in emp_no. 
ROUND(AVG(salary), 2) AS average_salary
emp_no, salary, MAX(from_date), MAX(to_date)
GROUP BY emp_no
ORDER BY emp_no) AS A;
Also, I would like to understand more about the Error Code 1248: Every derived table must have its own alias. What’s the point of having the alias when I do not use it when executing it? Is there a more elegant way to type the code? Thanks in advance. 🙂 

1 Answer

365 Team

Hi Vivian!
Thanks for reaching out.

  1. This is a great observation. Yes, it does work. In our example, we wanted to focus on creating a MySQL Procedure, hence we have simplified that part of the answer.
  2. Providing the specific query you are referring to may help in our explanation. However, in general, the idea is that you need to provide aliases when using a subquery, since this is a selection of information that exists only temporarily. You can say that it exists only “in the life of the query”, so to speak. Therefore, it needs to be given an alias for a reference.   

Hope this helps.

Thank you 🙂

7 months

You are welcome! 🙂

7 months