DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(mysql.info) example-maximum-row

Info Catalog (mysql.info) example-maximum-column (mysql.info) examples (mysql.info) example-maximum-column-group
 
 3.6.2 The Row Holding the Maximum of a Certain Column
 -----------------------------------------------------
 
 _Task: Find the number, dealer, and price of the most expensive
 article._
 
 This is easily done with a subquery:
 
      SELECT article, dealer, price
      FROM   shop
      WHERE  price=(SELECT MAX(price) FROM shop);
 
 Another solution is to sort all rows descending by price and get only
 the first row using the MySQL-specific `LIMIT' clause:
 
      SELECT article, dealer, price
      FROM shop
      ORDER BY price DESC
      LIMIT 1;
 
 * If there were several most expensive articles, each with a
 price of 19.95, the `LIMIT' solution would show only one of them.
 
Info Catalog (mysql.info) example-maximum-column (mysql.info) examples (mysql.info) example-maximum-column-group
automatically generated byinfo2html