[odb-users] DISTINCT clause usage problem

Boris Kolpackov boris at codesynthesis.com
Fri Jan 24 08:47:03 EST 2014


Hi Aleksey,

Енакаев Алексей <Aleksey.Enakaev at infotecs.ru> writes:

> Tell me please, if there is any way to create ODB object view with
> 'DISTINCT' clause on some column:
> 
> 'SELECT DISTINCT ON( id ) id, name, some_other_fileld FROM table1
> JOIN table2 ...'?

Unfortunately, because DISTINCT comes between SELECT and the select-
list, there is no way to use it with an object view. So your options
are:

1. Use a native view (Section 10.5) and specify the complete query.

2. Find a way to re-implement your query as a suffix for the WHERE
   clause. For example, using EXISTS.

Boris



More information about the odb-users mailing list