Funzioni pass-through (RAWSQL)
These RAWSQL pass-through functions send SQL expressions directly to the database, without first being interpreted by Tableau. If you have custom database functions that Tableau doesn't know about, you can use pass-through functions to call these custom functions.
Because Tableau doesn't interpret the expression, you must define the aggregation when necessary. Puoi utilizzare la versione di una funzione quando devi passare un'espressione RAWSQLAGG aggregata.
Le funzioni pass-through RAWSQL potrebbero non funzionare con origini dati federate (combinate in database diversi) o pubblicate.
Sintassi RAWSQL
Le funzioni RAWSQL sono di due tipi: disaggregate e aggregate. Questo è specificato nella prima parte del nome della funzione, RAWSQL o RAWSQLAGG. La parte finale del nome della funzione è il tipo di output, ad esempio BOOL, STRo INT. In all RAWSQL functions, the argument is "sql_expr", [arg1], ...[arg2]. Quando si scrive la funzione, è possibile utilizzare una sintassi %n di sostituzione per inserire il nome del campo o l'espressione corretta.
Sintassi di sostituzione %n
Your database won't usually understand the field names that are shown in Tableau. Because Tableau doesn't interpret the SQL expressions in the pass-through functions, using the Tableau field names in your expression may cause errors. Use %n to insert the correct field name or expression for a Tableau calculation into pass-through SQL.
Ad esempio, se avessi una funzione che calcola il valore mediano di un insieme di valori, potresti richiamare tale funzione nella colonna [Vendite] di Tableau in questo modo:
RAWSQLAGG_REAL("MEDIAN(%1)", [Sales])REALSQLAGGperché vuoi specificare l'aggregazione.REALPerché l'output è numerico e non necessariamente un numero intero.MEDIANis the aggregation.%1è il segnaposto per[Sales].
Funzioni RAWSQL
L’espressione SQL viene passata direttamente al database sottostante. Utilizza %n nell’espressione SQL come sintassi di sostituzione per i valori del database.
The following RAWSQL functions are available in Tableau:
RAWSQL_BOOL
| Sintassi | RAWSQL_BOOL("sql_expr", [arg1], …[argN]) |
| Output | Booleano |
| Definizione | Restituisce un risultato booleano da una data espressione SQL. |
| Esempio | RAWSQL_BOOL("%1 > %2", [Sales], [Profit])Nell’esempio, %1 è uguale a [Vendite] e %2 è uguale a [Profitto]. |
RAWSQLAGG_BOOL
| Sintassi | RAWSQLAGG_BOOL("sql_expr", [arg1], …[argN]) |
| Output | Booleano |
| Definizione | Restituisce un risultato booleano da una data espressione SQL aggregata. |
| Esempio | RAWSQLAGG_BOOL("SUM( %1) >SUM( %2)", [Sales], [Profit]) Nell’esempio, %1 è uguale a [Vendite] e %2 è uguale a [Profitto]. |
RAWSQL_DATE
| Sintassi | RAWSQL_DATE("sql_expr", [arg1], …[argN]) |
| Output | Data |
| Definizione | Returns a date result from a given SQL expression. |
| Esempio | RAWSQL_DATE("%1", [Order Date])In questo esempio, %1 è uguale a [Data ordine]. |
RAWSQLAGG_DATE
| Sintassi | RAWSQLAGG_DATE("sql_expr", [arg1], …[argN]) |
| Output | Data |
| Definizione | Returns a date result from a given aggregate SQL expression |
| Esempio | RAWSQLAGG_DATE("MAX(%1)", [Order Date])In questo esempio, %1 è uguale a [Data ordine]. |
RAWSQL_DATETIME
| Sintassi | RAWSQL_DATETIME("sql_expr", [arg1], …[argN]) |
| Output | Data e ora |
| Definizione | Returns a datetime result from a given SQL expression. |
| Esempio | RAWSQL_DATETIME("%1", [Order Date])In questo esempio, %1 è uguale a [Data ordine]. |
RAWSQLAGG_DATETIME
| Sintassi | RAWSQLAGG_DATETIME("sql_expr", [arg1], …[argN]) |
| Output | Data e ora |
| Definizione | Returns a datetime result from a given aggregate SQL expression. |
| Esempio | RAWSQLAGG_DATETIME("MIN(%1)", [Order Date])In questo esempio, %1 è uguale a [Data ordine]. |
RAWSQL_INT
| Sintassi | RAWSQL_INT("sql_expr", [arg1], …[argN]) |
| Output | Intero |
| Definizione | Restituisce come risultato un numero intero da una data espressione SQL. |
| Esempio | RAWSQL_INT("500 + %1", [Sales])In questo esempio, %1 è uguale a [Vendite]. |
RAWSQLAGG_INT
| Sintassi | RAWSQLAGG_INT("sql_expr", [arg1,] …[argN]) |
| Output | Intero |
| Definizione | Restituisce come risultato un numero intero da una data espressione SQL aggregata. |
| Esempio | RAWSQLAGG_INT("500 + SUM(%1)", [Sales])In questo esempio, %1 è uguale a [Vendite]. |
RAWSQL_REAL
| Sintassi | RAWSQL_REAL("sql_expr", [arg1], …[argN]) |
| Output | Numerico |
| Definizione | Returns a numeric result from a given SQL expression. |
| Esempio | RAWSQL_REAL("-123.98 * %1", [Sales])In questo esempio, %1 è uguale a [Vendite] |
RAWSQLAGG_REAL
| Sintassi | RAWSQLAGG_REAL("sql_expr", [arg1,] …[argN]) |
| Output | Numerico |
| Definizione | Returns a numeric result from a given aggregate SQL expression. |
| Esempio | RAWSQLAGG_REAL("SUM( %1)", [Sales])In questo esempio, %1 è uguale a [Vendite]. |
RAWSQL_SPATIAL
| Sintassi | RAWSQL_SPATIAL("sql_expr", [arg1], …[argN]) |
| Output | Spaziale |
| Definizione | Returns a spatial result from a given SQL expression. |
| Esempio | RAWSQL_SPATIAL("%1", [Geometry])In questo esempio, %1 è uguale a [Geometria]. |
| Note | There is no RAWSQLAGG version of this function. |
RAWSQL_STR
| Sintassi | RAWSQL_STR("sql_expr", [arg1], …[argN]) |
| Output | Stringa |
| Definizione | Returns a string from a given SQL expression. |
| Esempio | RAWSQL_STR("%1", [Customer Name])In questo esempio, %1 è uguale a [Nome cliente]. |
RAWSQLAGG_STR
| Sintassi | RAWSQLAGG_STR("sql_expr", [arg1,] …[argN]) |
| Output | Stringa |
| Definizione | Returns a string from a given aggregate SQL expression. |
| Esempio | RAWSQLAGG_STR("AVG(%1)", [Discount])In questo esempio, %1 è uguale a [Sconto]. |
