MySQL The World's Most Popular Open Source Database # Online shop | Site map |  
CompanyProductsSupport & ConsultingTraining & CertificationDownloadsDocumentation
  BooksArticlesMailing ListsPresentationsOther Sites  
Search the MySQL manual:
MySQL Manual
  • 3 Учебное пособие по MySQL
    • 3.5 Примеры стандартных запросов
      • 3.5.1 Максимальное значение столбца
      • 3.5.2 Строка, содержащая максимальное значение некоторого столбца
      • 3.5.3 Максимальное значение столбца для группы
      • 3.5.4 Строка, содержащая максимальное значение некоторого столбца
      • 3.5.5 Использование пользовательских переменных
      • 3.5.6 Использование внешних ключей
      • 3.5.7 Поиск по двум ключам
      • 3.5.8 Подсчет посещений за день
      • 3.5.9 Использование атрибута AUTO_INCREMENT

Buy this Reference Manual in softcover from Barnes & Noble!

MySQL Reference Manual
Previous / Next / Up / Table of Contents

3.5.1 Максимальное значение столбца

"Как определить наибольшее значение в столбце?"

SELECT MAX(article) AS article FROM shop

+---------+
| article |
+---------+
|       4 |
+---------+

User Comments

Posted by [name withheld] on Tuesday February 26 2002, @8:56am[Delete] [Edit]

When you select
max(date_format(col_name, "fstring"))
the maximum alphabetic string is returned, not
the maximum date. Need to create a temporary
table to get the max date, first, then select
again to format the date. Is this correct
behavior?

Posted by [name withheld] on Thursday August 29 2002, @10:04am[Delete] [Edit]

select max(col_name), date_format
(col_name, "fstring") group by col_name;

This is an add workaround, but it would work. This
would return the appropiate (most recent or
future) datetime value as the first item and its
formatted string as the second item. The biggest
loss would be performance, but not too much of it.

Add your own comment.

Top / Previous / Next / Up / Table of Contents
# MySQL.com home | Site map | Contact us | Press | Jobs | Privacy policy | Trademark info | © 1995-2003 MySQL AB. All rights reserved.