loading..
   English
11:07

ASCII and CHAR functions

Let's start from two reciprocally related functions - ASCII and CHAR.

The ASCII function returns an ASCII code value of the leftmost character of a character expression, being a function argument.

Here is an example of the way to determine how many different letters which the names of the ships in the Ships table start from are:

Console
Execute
  1. SELECT COUNT(DISTINCT ASCII(name))
  2. FROM Ships

The result is 11. To find out what these letters are, we can use CHAR function that returns a character by a known ASCII code value (from 0 to 255):

Console
Execute
  1. SELECT DISTINCT CHAR(ASCII(name))
  2. FROM Ships
  3. ORDER BY 1