Re: getting only the largest or smallest values in a select statement

From: Date: Mon, 09 Oct 2000 17:55:47 +0000
Subject: Re: getting only the largest or smallest values in a select statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19231@lists.php.net to get a copy of this message
Select Top 1 id, amount from table order by amount (to get the lowest amount) Select Top 1 id,amount from table order by amount desc (to get the highest amount) ----- Original Message ----- From: "Dave Gardner" <dgardner@exactax.com> To: <mysql@lists.mysql.com>; <php-general@lists.php.net> Sent: Friday, October 06, 2000 7:06 PM Subject: getting only the largest or smallest values in a select statement > 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? > > > > -- > --------------------------------------------------------------------- > Please check > "http://www.mysql.com/documentation/manual.php" before > posting. To request this thread, e-mail mysql-thread52712@lists.mysql.com > > To unsubscribe, send a message to: > <mysql-unsubscribe-matt=smokescreen.org@lists.mysql.com> > > If you have a broken mail client that cannot send a message to > the above address (Microsoft Outlook), you can use: > http://lists.mysql.com/php/unsubscribe.php >

« previous php.general (#19231) next »