Sorting Alphanumeric Fields

 

Many data fields in CrimeStar are designed to capture an alphanumeric value. When these fields are subsequently used by agencies to capture a strictly numeric value, there is often some confusion about the way these fields are sorted and represented on reports.

 

When dealing with numeric data fields CrimeStar evaluates the value of the field based on its number value. When doing so values appear in proper sequence. Example:

 

1

2

3

123

200

 

However when alphanumeric fields are sorted the database engine follows the basic rules that we would commonly refer to as alphabetizing. In this process character strings are evaluated from the left most position to the right most position and are ordered accordingly. Within this logic numeric characters always appear before alphabetic characters. Please note in this situation there is a distinct difference between a numeric value and a numeric character.

Example: 123 by value is (one hundred twenty three) while 123 by character is (one, two, three). The following is an example of an alphanumeric sort.

 

1

123

2

200

3

A

B

C

 

Note that when evaluating the left most character positions they are in the proper alphabetized order. When using a CrimeStar alphanumeric data field for numeric values only, you can cause the characters to appear in proper numeric sequence by preceding the numeric character with the appropriate number of leading zeros. Example:

 

001

002

003

123

200

A

B

C

 

By adding the leading zeros alphanumeric values are sorted into a sequence consistent with that of true numeric digits.