Joins on Encrypted Columns

SAP ASE optimizes the joining of two encrypted columns by performing cipher text comparisons under certain circumstances.

This example sets a schema to join on cipher text:
create encryption key new_cc_key for AES
        with init_vector NULL
create table customer
        (custid int,
        creditcard char(16) encrypt with new_cc_key)
create table daily_xacts
       (cust_id int, creditcard char(16) encrypt with
        new_cc_key, amount money........)
You can also set up indexes on the joining columns:
create index cust_cc on customer(creditcard)create index daily_cc on daily_xacts(creditcard)
SAP ASE executes the following select statement to total a customer’s daily charges on a credit card without decrypting the creditcard column in either the customer or the daily_xacts table.
select sum(d.amount) from daily_xacts d, customer c
     where d.creditcard = c.creditcard and
     c.custid = 17936