
Sale_person_name, MAX(no_products_sold) AS MaxSale Observe the below query, it’s output, and explanation. We need to do an inner join of the sales_details table with a derived table for the desired result. We will be using the same table sale_details to get all the columns for a salesperson corresponding to the row, which shows the maximum sale for a product department wise.
Mysql union every derived table must have its own alias how to#
Let’s see how to work with joins while using the derived tables. On running the query now, we get the desired result.Īction Output Message: SELECT CEIL(AVG(max_sales)) FROM (SELECT sale_person_name, MAX(no_products_sold) AS max_sales FROM sale_details GROUP BY sale_person_name)as sales_alias LI1 row(s) returned 0.00086 sec / 0.000018 sec.Įvery derived table must have its own alias : JOIN In the above query, we have added an alias sales_alias for the derived table. GROUP BY sale_person_name) AS sales_alias Sale_person_name, MAX(no_products_sold) AS max_sales Observe the corrected query below: SELECTĬEIL(AVG(max_sales)) AS average_of_max_sales_per_salesman The reason for the same is that we need to provide an alias for the sub-queries while working in MySQL( alias is just a temporary/false name). It is highlighting that an Error:1248 Every derived table must have its alias has occurred. Every derived table must have its own alias 0.00025 sec Python - Access Nth item in List Of TuplesĪction Output Message: SELECT CEIL(AVG(max_sales)) FROM (SELECT sale_person_name, MAX(no_products_sold) AS max_sales FROM sale_details GROUP BY sale_person_name) LIError Code: 1248. Python - Check if a value is in Dictionary Python - Returning Multiple Values in Function


Remove Every Nth Element From a NumPy Array.Remove Elements from a NumPy Array in a specific order.Remove The Middle Element from a NumPy Array.

Looking for Something Search for: Search Recent Posts
