What is the simplest way to find the largest value of a field when there are 2 or more results?
I've been playing with the W3Schools site using the orders table. I've tried to display all the rows with the largest employee number (9). Here is the link - http://www.w3schools.com/sql/trysql.asp?filename=trysql_func_avg
I can only figure out how to get it to print out one row. How can I get it to print all of the results?
I tried the following:
select max(EmployeeID)
from orders;
and just get the result of 9. I'm having trouble getting my head around this.
max(EmployeeID)returns the greatest value ofEmployeeIDin the table. There can only be one maximum number, so 9 is the whole result of that query. Just as there can be only one result for average, as in the sample you linked to.