I am struggling to understand the use of GROUP BY
in this question and clarify (Help: integer, from: string: from: string, distance: integer, departure: time comes: time, value: real) plane (help: integer, Anonym: String
The question is: Cruising Ranging for all aircraft, cruising Ranges: integer) certified (EID: East Ank aid: integer) Employees (EID: integer, Enam: string, salary: integer) at a distance of 1,000 miles, the plane's name and get certified average salary of all pilots of the plane.
SELECT temp.name, Temp.AvgSalary FROM (SELECT A.aid, A.aname AG (ESLARI) AAGSLARIER FIERX A, CERTIFIED C, EMPLOYES E AK ADE = CAD AND CYD = EED And a cruiserange arac> 1000 group by AED, A.Enam) ASTP
Why is GROUP BY
required here? Will the following questions do not return the plane and this pay, or will it pay back the average salary of all employees not being specific to each aircraft?
SELECT A.aname, AVG (E.salary) aircraft A, certified C, employee E to Aid = CAD and CDE = EEED and A CRUSICARGANG & gt; 1000
uses GROUP BY
changes the format of the table so that using GROUP BY A.aid
will specify that Are we just classifying the plane table and leaving certified and employee's table untouched?
(In this case, taking the average) properly
If you do not group anything, then MySQL will implement this entire compilation on your entire table. In other words, if you used your previous question, it will return the average salary for all planes with a limit of more than 1000, from which there is no difference, in which the plane is. Try it, and you will see this behavior.
However, if you use the GROUP BY
section, you will see the average for each personal plane with more than 1000 cruising rows, which Without that what you want, you are taking the average of all planes.
Try these questions on some questions, and the difference in behavior will become more clear.
Edit
About some of your last statements: Yes, we are not doing anything with certified or employee table retreat For, the problem is for each aircraft many times, if you are given a problem statement that gives a message to the group of essential things for you, then it is a section in the form of your group As is a good start to establish.
No comments:
Post a Comment