|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
select max values
Hello. I need some help with an sql statement. Maybe one can help.
I got this table: employee,value,zone 11,1541,0 11,1300,0 11,1810,1 11,1710,1 11,2000,2 11,1900,2 applying this statement: select max(value),employee,zone from table group by employee,zone; ... delivers this result: max(value),employee,zone 1541,11,0 1810,11,1 2000,11,2 All I want to get is one single line per employee, since I'm only interested in that row which has the largest values among the employees' data. I expect this result: 11,2000,2 Can anyone help me out with the statement? Many thanks Milorad |
|
#2
|
|||
|
|||
|
Code:
select value,employee,zone from t as q where value = (select max(value) from t where t.employee = q.employee) |
|
#3
|
||||
|
||||
|
You will get the same result if you run this query:
Code:
SELECT FIRST 1 VALUE,EMPLOYEE,ZONE FROM TABLE ORDER BY VALUE DESC
__________________
If i've been helpful, please add to my reputation. My unfinished site: http://www.dever.ro |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > select max values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|