Distinct Views

You can ensure that the rows contained in a view are unique.

For example:
create view author_codes
as select distinct au_id
from titleauthor

A row is a duplicate if all of its column values match the same column values contained in another row. Two null values are considered to be identical.

SAP ASE applies the distinct requirement to a view definition when it accesses the view for the first time, before it performs any projecting or selecting. Views look and act like any database table. If you select a projection of the distinct view (that is, you select only some of the view’s columns, but all of its rows), you can get results that appear to be duplicates. However, each row in the view itself is still unique. For example, suppose that you create a distinct view, myview, with three columns, a, b, and c, that contains these values:

a

b

c

1

1

2

1

2

3

1

1

0

When you enter this query:

select a, b from myview

the results look like this:

a    b
---  ---
1    1
1    2
1    1
 
(3 rows affected)

The first and third rows appear to be duplicates. However, the underlying view’s rows are still unique.