getting only the largest or smallest values in a select statement
| From: | Dave Gardner | Date: | Fri, 06 Oct 2000 23:06:53 +0000 |
| Subject: | getting only the largest or smallest values in a select statement | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18998@lists.php.net to get a copy of this message | ||
How can I get the largest (or smallest) value of a column in multiple records, culled from a select statement? Let's say I did a 'select id, amount from purchases' and got the following:
id amount
-- -------
1 488
2 1256
3 188
4 97
5 166
Is it possible to modify the query itself to select only the largest or smallest value in 'amount' as displayed here? Or is there something I need to do in PHP to figure that out?