mysql - SQL max() function returns wrong value for row with maximum value -
this table structure:
anees 1000.00 rick 1200.00 john 1100.00 stephen 1300.00 maria 1400.00
i trying find max(salary) , persons name .
this query use
select max(salary),emp_name emp1
i 1400.00 , anees.
while 1400 correct anees wrong,it should maria. changes need make
gordon gave explanation why , simplest way want want. if reason want use max()
can this
select emp_name, salary emp1 salary = ( select max(salary) salary emp1 )
output:
| emp_name | salary | --------------------- | maria | 1400 |
here sqlfiddle demo
Comments
Post a Comment