Wednesday, March 7, 2012

How to do this?

I need to select the row that has the highest value for a particular field.

For example, lets say we have an employee table, and an employee can appear more than 1 time because an employee has several job functions:

Emp_Id 1
Function Clerk

Emp_Id 1
Function Manager

I need to select the row with the highest function, in this case manager( because m > c)

How can i do this, lets say the table name is Employee.SELECT MAX(Emp_id)?|||Thanks :)

This is the query that I got.

SELECT EMP_ID, MAX(FUNCTION)
GROUP BY EMP_ID

No comments:

Post a Comment