December 8th, 2008

CHAR_LENGTH (no. of characters)

CHARACTER_LENGTH gives the number of characters in a character string (not the number of bytes)
and returns an integer.

Format:                         CHARACTER_LENGTH(string)

Example:           SELECT CUST_NAME,
                          CHARACTER_LENGTH(CUST_NAME) AS 'LENGTH'
                     FROM CUSTOMER_TBL;

Result:

                   

> The length of an empty string (’ ‘) is zero.
> Access uses LEN(string) to find the number of characters.
> DB2 and Oracle use LENGTH(string) to find the number of characters.
> SQL Server uses DATALENGTH(string) to find the number of characters.
> MySQL uses BIT_COUNT(string) to find the number of bits.
> Oracle uses LENGTHB(string) to find the number of bits.
> CHARACTER_LENGTH and CHAR_LENGTH are synonymous.

December 5th, 2008

CEILING or CEIL (round upward)

The CEILING function returns the smallest integer greater than the input value.

Format:            CEILING(expression)
Example:           SELECT CEILING(10.2) FROM TABLEA;

Result:

                    

> DB2 supports CEILING and CEIL.

> MySQL, and SQL Server support only CEILING.

> Oracle supports only CEIL.

> Access, PostgreSQL, and Sybase don’t support CEILING or CEIL.

> CEILING and CEIL are synonymous.

 

December 4th, 2008

BIT_LENGTH (no. of bits)

The BIT_LENGTH function returns the number of bits contained in the value of the argument.

Format: BIT_LENGTH(expression)
Example: SELECT BIT_LENGTH('ABC') FROM TABLEA;

Result:

                   

> PostgreSQL, and Sybase support BIT_LENGTH.

> Access, DB2, MySQL, Oracle, and SQL Server don’t support BIT_LENGTH.

> Oracle uses LENGTHB.

 

December 3rd, 2008

ABSOLUTE or ABS (absolute value)

The ABSOLUTE or ABS function converts the numeric value in the argument to its absolute value. In other words, a negative value is changed to a positive value.

Format:            ABS(expression)
Example:           SELECT ABS(-1) FROM TABLEA;

Result:

                   

> Access, DB2, MySQL, PostgreSQL, SQL Server, and Sybase support the ABS function.> ABSOLUTE and ABS are synonymous.

 

« Previous Page