---
title: "Funzione di aggregazione Max"
description: "Funzione di gruppo che calcola il valore massimo di un gruppo di valori numerici o testuali."
language: it
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/it/docs/invantive-universalsql/grammar/aggregate-functions/max-aggregate-function
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/aggregate-functions/max-aggregate-function
updated: 2026-11-21T18:48:39Z
license: https://documentation.invantive.eu/it/
---

## Sintassi
```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_1 --> maxAggregateFunction_0_1a[DISTINCT]:::quoted
    maxAggregateFunction_0_1 --> maxAggregateFunction_0_1b[ALL]:::quoted
    maxAggregateFunction_0_1a --> maxAggregateFunction_0_2
    maxAggregateFunction_0_1b --> maxAggregateFunction_0_2
    maxAggregateFunction_0_2 --> maxAggregateFunction_0_3[")"]:::quoted
    maxAggregateFunction_0_3 --> maxAggregateFunction_end((END))
```

## Scopo
Funzione di gruppo che calcola il valore massimo di un gruppo di valori numerici o testuali. Le occorrenze di `null` vengono ignorate; quando sono presenti solo valori `null`, il risultato è `null`. I testi sono confrontati in base al codice di ciascun carattere (ordinale), come in `order by`, quindi il massimo tra `'a'` e `'B'` è `'a'`. Fino alla release 27.0 i testi venivano confrontati in base alle impostazioni di lingua del computer. Per trovare il valore più grande tra più valori all'interno di una riga, usare [[GREATEST]]. `DISTINCT` e `ALL` sono accettati a partire dalla release 28.0 e non modificano il risultato.

## Esempi
Il seguente esempio recupera il limite di credito più alto su una base clienti di cinque clienti:
```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
```
Il seguente esempio recupera il saldo aperto più alto per segmento di clienti; il saldo dell'unico cliente Services è `null`, quindi il risultato per quel segmento è vuoto:
```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
```

