MAX

توضیحات

این تابع مقدار ماکسیمم لیست را برمی‌گرداند.

دستور

تابع MAX به صورت زیر نوشته می‌شود:

۱
۲
۳
SELECT MAX(aggregate_expression)
FROM tables
[WHERE conditions];

.


مثال

مثال‌هایی از خروجی تابع log را مشاهده می‌کنیم:

۱
۲
۳
۴
۵
۶
۷
۸
۹
۱۰
۱۱
۱۲
۱۳
۱۴
۱۵
۱۶
۱۷
SELECT MAX(salary) AS \"Highest Salary\"
FROM employees;
SELECT department, MAX(salary) AS \"Highest salary\"
FROM employees
GROUP BY department;
SELECT report_name, MAX(report_run_date)
FROM report_history
GROUP BY report_name
SELECT rh.user_name, rh.report_name, rh.report_run_date
FROM report_history rh,
  (SELECT MAX(report_run_date) AS maxdate, report_name
   FROM report_history
   GROUP BY report_name) maxresults
WHERE rh.report_name = maxresults.report_name
AND rh.report_run_date= maxresults.maxdate;
Categories: Data
X