Difference between revisions of "SQL MAX()"

From Lianjapedia
Jump to: navigation, search
 
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Returns a maximum value in a SELECT statement
 
Returns a maximum value in a SELECT statement
 
  
 
==Syntax==
 
==Syntax==
MAX(<expr>)
+
MAX(<expr1> [, <expr2> [, ...]])
 
+
  
 
==See Also==
 
==See Also==
 
[[SQL Aggregate Functions|AGGREGATES]], [[AVG()]], [[COUNT()]], [[SQL MIN()|MIN()]], [[SQL SELECT|SELECT]], [[SUM()]]
 
[[SQL Aggregate Functions|AGGREGATES]], [[AVG()]], [[COUNT()]], [[SQL MIN()|MIN()]], [[SQL SELECT|SELECT]], [[SUM()]]
  
 +
==Description==
 +
Returns the maximum value of <expr1> or the list of expressions (list supported from v6.0).
  
Description
+
The expressions can be of the following data types:
Returns the maximum value of <expr>.  The <expr> can be a numeric or date expression.
+
* Numeric
 
+
* Date
 +
* Character (from v6.0)
 +
* Currency (from v6.0)
 +
* Datetime (from v6.0)
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
SELECT MAX(sal) Maximum FROM accounts
+
open database southwind
 +
select max(orderdate,requireddate,shippeddate) from orders
 +
select max(companyname) from customers
 
</code>
 
</code>
  
 
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL|MAX()]]
 
[[Category:SQL|MAX()]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 +
[[Category:SQL Functions]]
 +
[[Category:Lianja v6.0]]

Latest revision as of 06:37, 23 February 2021

Purpose

Returns a maximum value in a SELECT statement

Syntax

MAX(<expr1> [, <expr2> [, ...]])

See Also

AGGREGATES, AVG(), COUNT(), MIN(), SELECT, SUM()

Description

Returns the maximum value of <expr1> or the list of expressions (list supported from v6.0).

The expressions can be of the following data types:

  • Numeric
  • Date
  • Character (from v6.0)
  • Currency (from v6.0)
  • Datetime (from v6.0)

Example

open database southwind
select max(orderdate,requireddate,shippeddate) from orders
select max(companyname) from customers