## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR maxAggregateFunction_start((START)) maxAggregateFunction_start --> maxAggregateFunction_0_0[MAX]:::quoted maxAggregateFunction_0_0 --> maxAggregateFunction_0_1["("]:::quoted maxAggregateFunction_0_1 --> maxAggregateFunction_0_2[<a href="Invantive UniversalSQL/Grammar/Expression" class="internal-link">expression</a>] maxAggregateFunction_0_2 --> maxAggregateFunction_0_3[")"]:::quoted maxAggregateFunction_0_3 --> maxAggregateFunction_end((END)) ``` ## Purpose Group function to find the maximum value from a group of numerical values or text values. Occurrences of `null` are ignored; when solely `null` values are present, the outcome is `null`. ## Examples The following example retrieves the highest credit limit across a customer base of five customers: ```sql select max(cus.credit_limit) from csvtable ( passing 'Acme Industries#Manufacturing#12500#50000|Bergmann GmbH#Manufacturing#0#25000|Carlson Ltd#Wholesale#2500#10000|Dubois SA#Wholesale#7500#10000|Everest BV#Services##5000' row delimiter '|' column delimiter '#' columns name varchar2 position next , segment varchar2 position next , balance number position next , credit_limit number position next ) cus ------------------- 50000 ``` The following example retrieves the highest outstanding balance per customer segment; the balance of the sole Services customer is `null`, so the outcome for that segment is empty: ```sql select cus.segment , max(cus.balance) from csvtable ( passing 'Acme Industries#Manufacturing#12500#50000|Bergmann GmbH#Manufacturing#0#25000|Carlson Ltd#Wholesale#2500#10000|Dubois SA#Wholesale#7500#10000|Everest BV#Services##5000' row delimiter '|' column delimiter '#' columns name varchar2 position next , segment varchar2 position next , balance number position next , credit_limit number position next ) cus group by cus.segment order by cus.segment ------------------- Manufacturing 12500 Services Wholesale 7500 ```