Skip to main content


A collation function that converts numbers to canonical collation format, then inverts the sign.



%MINUS expression


%MINUS converts numbers or numeric strings to canonical form, inverts the sign, then returns these expression values in numeric collation sequence.

%MINUS and %PLUS are functionally identical, except that %MINUS inverts the sign. It prefixes a minus sign to any number that resolves to a positive number, and removes the minus sign from any number that resolves to a negative number. Zero is never signed.

A number can contain leading and trailing zeros, multiple leading plus and minus signs, a single decimal point indicator (.), and the E exponent indicator. In canonical form, all arithmetic operations are performed, exponents are expanded, signs are resolved to either a single leading minus sign or no sign, and leading and trailing zeros are stripped.

A numeric literal can be specified with or without enclosing string delimiters. If a string contains non-numeric characters, %MINUS truncates the number at the first non-numeric character, and returns the numeric part in canonical form. A non-numeric string (any string that begins with a non-numeric character) is returned as 0. %MINUS also returns NULLs as 0.

%MINUS is an InterSystems SQL extension and is intended for SQL lookup queries.

You can perform the same collation conversion in ObjectScript using the Collation()Opens in a new tab method of the %SYSTEM.UtilOpens in a new tab class:

  WRITE $SYSTEM.Util.Collation("++007.500",4)

Compare %MINUS to %MVR collation, which sorts a string based on the numeric substrings within the string.



An expression, which can be the name of a column, a number or a string literal, an arithmetic expression, or the result of another function, where the underlying data type can be represented as any character type.


The following example uses %MINUS to return records in descending numeric order of the home street number:

SELECT Name,Home_Street
FROM Sample.Person
ORDER BY %MINUS(Home_Street)

Note that the above example orders the integer part of the street address in numerical order. Compare this with the following ORDER BY DESC example, which orders records by street addresses in collation sequence:

SELECT Name,Home_Street
FROM Sample.Person

See Also

FeedbackOpens in a new tab