Gossamer Forum
Home : General : Databases and SQL :

Confused about MIN() and MAX()...

Quote Reply
Confused about MIN() and MAX()...
Ok...this has me a little confused. The MySQL Manual (on group by) has the following to say;

Quote:
mysql> SELECT student_name, MIN(test_score), MAX(test_score)
-> FROM student
-> GROUP BY student_name;

Is this saying that both MIN() and MAX() have to be defined?

All I want/need to do is get the MAX() number held in the 'Weight' field Unsure It would really help now, and in future stuff if I could understand how this worked...as it looks like it could be as useful as the WHERE clause Smile

Cheers in advance.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Confused about MIN() and MAX()... In reply to
SELECT MAX(Weight) FROM table
Quote Reply
Re: [Paul] Confused about MIN() and MAX()... In reply to
So there is no way to do what I want in one query, like below?

SELECT * FROM Users WHERE Weight <= MAX(Weight)

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Confused about MIN() and MAX()... In reply to
Well for starters that where clause (if it were to work) is exactly the same as:

select * from Users

...as every row will of course be less or equal to the max weight.

Last edited by:

Paul: Jan 22, 2003, 2:54 AM
Quote Reply
Re: [Paul] Confused about MIN() and MAX()... In reply to
Ok, < MAX(Weight)

Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!