Helper functions

The query editing tool allows you to use advanced functions to carry out complex filtering depending on the desired results and the types of manipulated data. The following functions are available:

Aggregate

The aggregate functions are used to perform calculations on a set of values.

NameDescriptionSyntax
AvgReturns the average of a number type columnAvg(<value>)
CountCounts the non-null values of a columnCount(<value>)
CountAllCounts the values returned (all fields)CountAll()
CountdistinctCounts the distinct non-null values of a columnCountdistinct(<value>)
MaxReturns the maximum value of a number, string, or date type columnMax(<value>)
MinReturns the minimum value of a number, string or date type columnMin(<value>)
StdDevReturns the standard deviation of a number, string or date columnStdDev(<value>)
StringAggReturns the concatenation of the values of a string type column, separated by the character in the second argumentStringAgg(<Value>, <String>)
SumReturns the sum of the values of a number, string, or date type columnSum(<value>)

Date

The date functions are used to manipulate date or time values.

NameDescriptionSyntax
AddDaysAdds a number of days to a dateAddDays(<date>, <number>)
AddHoursAdds a number of hours to a dateAddHours(<date>, <number>)
AddMinutesAdds a number of minutes to a dateAddMinutes(<date>, <number>)
AddMonthsAdds a number of months to a dateAddMonths(<date>, <number>)
AddSecondsAdds a number of seconds to a dateAddSeconds(<date>, <number>)
AddYearsAdds a number of years to a dateAddYears(<date>, <number>)
ConvertNTZConverts timestamp NTZ (timestamp without timezone) into TZ (timestamp with timezone) applying defined session TZConvertNTZ (<date+time>)
DateCmpCompare two datesDateCmp(<date>,<date>)
DateOnlyReturns the date only (with time at 00:00)*DateOnly(<date>)
DayReturns the number representing the day of the dateDay(<date>)
DayOfYearReturns the number of the day in the year of the dateDayOfYear(<date>)
DaysAgoReturns the date corresponding to the current date minus n daysDaysAgo(<number>)
DaysAgoIntReturns the date (integer yyyymmdd) corresponding to the current date minus n daysDaysAgoInt(<number>)
DaysDiffNumber of days between two datesDaysDiff(<end date>, <start date>)
DaysOldReturns the age in days of a dateDaysOld(<date>)
GetDateReturns the current system date of the serverGetDate()
HourReturns the hour of the dateHour(<date>)
HoursDiffReturns the number of hours between two datesHoursDiff(<end date>, <start date>)
MinuteReturns the minutes of the dateMinute(<date>)
MinutesDiffReturns the number of minutes between two datesMinutesDiff(<end date>, <start date>)
MonthReturns the number representing the month of the dateMonth(<date>)
MonthsAgoReturns the date corresponding to the current date minus n monthsMonthsAgo(<number>)
MonthsDiffReturns the number of months between two datesMonthsDiff(<end date>, <start date>)
MonthsOldReturns the age in months of a dateMonthsOld(<date>)
OldestReturns the oldest date in a rangeOldest (<date, date>)
SecondReturns the seconds of the dateSecond(<date>)
SecondsDiffReturns the number of seconds between two datesSecondsDiff(<end date>, <start date>)
SubDaysSubtracts a number of days from a dateSubDays(<date>, <number>)
SubHoursSubtracts a number of hours from a dateSubHours(<date>, <number>)
SubMinutesSubtracts a number of minutes from a dateSubMinutes(<date>, <number>)
SubMonthsSubtracts a number of months from a dateSubMonths(<date>, <number>)
SubSecondsSubtracts a number of seconds from a dateSubSeconds(<date>, <number>)
SubYearsSubtracts a number of years from a dateSubYears(<date>, <number>)
ToDateConverts a date + time as a dateToDate(<date + time>)
ToDateTimeConverts a string to a date + timeToDateTime(<string>)
ToTimestampConverts a string to a timestampToTimestamp(<string>)
ToTimeZoneConvert a date + time to time zoneToTimeZone(<date>,<time zone>)
TruncDateRounds a date+time to the nearest secondTruncDate(@lastModified, <number of seconds>)
TruncDateTZRounds a date + time to a given precision expressed in secondsTruncDateTZ(<date>, <number of seconds>, <time zone>)
TruncQuarterRounds a date off to the quarterTruncQuarter(<date>)
TruncTimeRounds the time part up to the nearest secondTruncTim(e<date>, <number of seconds>)
TruncWeekRounds a date off to the weekTruncWeek(<date>)
TruncYearRounds a date + time to January 1st of the yearTruncYear(<date>)
WeekDayReturns a number representing the day in the week of the date (0=Monday, 6=Sunday)WeekDay(<date>)
YearReturns the number representing the year of the dateYear(<date>)
YearAnd MonthReturns the number representing the year and month of the dateYearAndMonth(<date>)
YearsAgoReturns the number of years between a given date and the current dateYearsAgo(<date>)
YearsDiffReturns the number of years between the two datesYearsDiff(<end date>, <start date>)
YearsOldReturns the age in years of a dateYearsOld(<date>)
NOTE
Note that the Dateonly function takes into account the server’s timezone, not the operator’s.

Geomarketing

The geomarketing functions are used to manipulate geographical values.

NameDescriptionSyntax
DistanceReturns the distance between two points defined by their longitude and latitude, expressed in degrees.Distance(<Longitude A>, <Latitude A>, <Longitude B>, <Latitude B>)

Numeric

The numeric functions are used to convert text to numbers.

NameDescriptionSyntax
AbsReturns the absolute value of a numberAbs(<number>)
CeilReturns the lowest integer greater than or equal to a numberCeil(<number>)
FloorReturns the greatest integer greater than or equal to a numberFloor(<number>)
GreatestReturns the greater of two numbersGreatest(<number 1>, <number 2>)
LeastReturns the smaller of two numbersLeast(<number 1>, <number 2>)
ModReturns the remainder of the integer division of n1 by n2Mod(<number 1>, <number 2>)
PercentReturns the ratio of two numbers expressed as a percentagePercent(<number 1>, <number 2>)
RandomReturns the random valueRandom()
RoundRounds off a number to n decimalsRound(<number>, <number of decimals>)
SignReturns the sign of the numberSign(<number>)
ToDoubleConverts an integer to a floatToDouble(<number>)
ToInt64Converts a float to a 64 bit integerToInt64(<number>)
ToIntegerConverts a float to an integerToInteger(<number>)
TruncTruncates n1 to n2 decimalsTrunc(<n1>, <n2>)

Others

This table contains the remaining functions available.

NameDescriptionSyntax
AESEncryptEncrypt string provided in argumentAESEncrypt(<value>)
CaseReturns value 1 if the condition is true. If not, it returns value 2.Case(When(<condition>, <value 1>), Else(<value 2>))
ClearBitDeletes the Flag in the valueClearBit(<identifier>, <flag>)
CoalesceReturns value 2 if value 1 is zero or null, otherwise returns value 1Coalesce(<value 1>, <value 2>)
DecodeReturns value 3 if value 1 = value 2. If not returns value 4.Decode(<value 1>, <value 2>, <value 3>, <value 4>)
ElseReturns value 1 (may only be used as a parameter of the case function)Else(<value 1>, <value 2>)
GetEmailDomainExtracts the domain from an email addressGetEmailDomain(<value>)
GetMirrorURLRetrieves the URL of the mirror page serverGetMirrorURL(<value>)
IifReturns value 1 if the expression is true. If not, returns value 2Iif(<condition>, <value 1>, <value 2>)
IsBitSetIndicates whether the Flag is in the valueIsBitSet(<identifier>, <flag>)
IsEmptyStringReturns value 2 if string 1 is empty, otherwise returns value 3IsEmptyString(<value 1>, <value 2>, <value 3>)
NewUUIDReturns a unique IDNewUUID()
NoNullReturns the empty string if the argument is NULLNoNull(<value>)
RowIdReturns the line numberRowId
SetBitForces the Flag in the valueSetBit(<identifier>, <flag>)
ToBooleanConverts a number into a BooleanToBoolean(<number>)
WhenReturns value 1 if the expression is true. If not, it returns value 2 (may only be used as a parameter of the case function)When(<condition>, <value 1>)

String

The string functions are used to manipulate a set of strings.

NameDescriptionSyntax
AllNonNull2Indicates if all parameters are non-null and not emptyAllNonNull2(<string>, <string>)
AllNonNull3Indicates if all parameters are non-null and not emptyAllNonNull3(<string>, <string>, <string>)
AsciiReturns the ASCII value of the first character in the string.Ascii(<string>)
CharReturns the character corresponding to the 'n' ASCII codeChar(<number>)
CharindexReturns the position of string 2 in string 1.Charindex(<string>, <string>)
dataLengthReturns the size in bytes of the stringdataLength(<string>)
GetLineReturns the nth (from 1 to n) line of the stringGetLine(<string>)
IfEqualsReturns the third parameter if the first two parameters are equal. If not, returns the last parameterIfEquals(<string>, <string>, <string>, <string>)
IsMemoNullIndicates if the memo passed as a parameter is nullIsMemoNull(<memo>)
JuxtWordsConcatenates the strings passed as parameters. Adds spaces between the strings if necessary.JuxtWords(<string>, <string>)
JuxtWords3Concatenates the strings passed as parameters. Adds spaces between the strings if necessaryJuxtWords3(<string>, <string>, <string>)
LeftReturns the first n characters of the stringLeft(<string>, <number>)
LengthReturns the length of the stringLength(<string>)
LineExtract line n from stringLine(<string>,<number>)
LowerReturns the string in lowercaseLower(<string>)
LPadReturns the completed string on the leftLPad (<String>, <Number>, <Char>)
LtrimRemoves spaces to the left of the stringLtrim(<string>)
Md5DigestReturns an hexadecimal representation of the MD5 key of a stringMd5Digest(<string>)
MemoContainsSpecifies whether the memo contains the string passed as a parameterMemoContains(<memo>, <string>)
NodeValueExtracts the value of an XML field from its XPath and the field dataNodeValue (<String>, <String>)
ReplaceReplaces all occurrences of a specified string value with another string value.Replace(<String>,<String>,<String>)
RightReturns the last n characters of the stringRight(<string>)
RPadReturns the completed string on the rightRPad(<string>, <number>, <character>)
RtrimRemoves spaces to the right of the stringRtrim(<string>)
Sha256DigestHexadecimal representation of the SHA256 key of a string.Sha256Digest (<String>)
Sha512DigestHexadecimal representation of the SHA512 key of a string.Sha512Digest (<String>)
SmartReturns the string with the first letter of each word in capitalsSmart(<string>)
SubstringExtracts the substring starting at character n1 of the string and of length n2Substring(<string>, <offset>, <length>)
ToStringConverts the number to a stringToString(<number>, <number>)
UpperReturns the string in capitalsUpper(<string>)
VirtualLinkReturns the foreign key of a link passed as a parameter if the other two parameters are equalVirtualLink(<number>, <number>, <number>)
VirtualLinkStrReturns the foreign (text) key of a link passed as a parameter if the other two parameters are equalVirtualLinkStr(<string>, <number>, <number>)

Window

NameDescriptionSyntax
_Over__Execute the SQL function call entered as 1st parameter, over Partition or Order By the fields entered as 2nd parameter_Over_ (<Value>, <Value>)
DescApplies a descending sortDesc(<value 1>)
OrderBySorts the result within the partitionOrderBy(<value 1>)
PartitionByPartitions the result of a query on a tablePartitionBy(<value 1>)
RowNumGenerates a line number based on the table partition and on a sorting sequence.RowNum(PartitionBy(<value 1>), OrderBy(<value 1>))
Previous pageBuild your first query
Next pageAudit Trail