frlae hier bij mij ....
beeke vanalles

hij 'skipt' bvb name in de result

On 02/07/2010 11:06, Kenny Billiau wrote:
Ow that sucks :/


.. but what is wrong?

On Fri, 2 Jul 2010, Frederik Delaere wrote:

doesn't give correct results :(

Kenny Billiau wrote:
If you want the unique rows, use distinct. If you want the highest score
per person, you'll have to use group by with an aggregate function ;)

SELECT name, max(score)
FROM table
GROUP BY name
ORDER BY score DESC
LIMIT 0,3

Kenny


On Fri, 2 Jul 2010, Lieven Sterck wrote:

 SELECT DISTINCT name, score FROM .....

djebus, even I know that !! 8-)

On 02/07/2010 10:23, Frederik Delaere wrote:
lets say I have this data

id   name   score
1   dude1     9.1
2   dude2   9.5
3   dudette1 9.0
4   dude1    9.3
5  dudette1 8.5

And I want to select highest 3 scores:

SELECT score FROM table ORDER BY score DESC LIMIT 0,3

result will be

9.5
9.3
9.1

but how can I select both the name and the score and I only want one
score per person

I can do: SELECT DISTINCT name FROM table ORDER BY score DESC LIMIT 0,3
this will give me the correct names in the correct order, but I want
their score also

is this possible in one query ?


thanksuwel !

--
======================================================================
Kenny Billiau                          Bioinformatics Group / GoFORSYS
Scientific Programmer
+49 331 567 8626                             billiau@mpimp-golm.mpg.de
Max Planck Institute for Molecular Plant Physiology
Am Mühlenberg 1, 14476 Potsdam-Golm, Germany
http://bioinformatics.mpimp-golm.mpg.de         http://www.goforsys.de
======================================================================
_______________________________________________ Binari Implicitly Neglects All Recursive Iterations https://maillist.psb.ugent.be/mailman/listinfo/binari

-- 
==============================================================
Lieven Sterck, PhD

Tel:+32 (0)9 3313821                       Fax:+32 (0)9 3313809
VIB Department of Plant Systems Biology, UGent
Bioinformatics and Evolutionary Genomics Division
Technologiepark 927,         B-9052 Gent,             Belgium
Email: lieven.sterck@psb.vib-ugent.be
Website: http://bioinformatics.psb.ugent.be

==============================================================
"Facts are meaningless. You could use facts to prove anything 
that's even remotely true"   - H. Simpson