Selecting maximum value row using documentum query language (dql)

369 views Asked by At

I have a few columns let's say

r_object_id, date, c, d, e, f

Now I want to have results such that only the object id row with maximum maximum dates remains

Eg: If the values are

R1, 29nov, c1,d1,e1,F1
R1, 30nov, c2,d2,e2,f2
R2, 20nov, c3,d3,e3,f3
R2, 25nov, c4,d4,e4,f4

The result should be 
R1, 30nov, c2,d2,e2,f2
R2, 25nov, c4,d4,e4,f4

I'm not able to use max with group by for this as the other columns are different and I need results in a way that all columns can be seen , is there a way this can be achieved using documentum query language (dql)

1

There are 1 answers

2
Miki On
SELECT r_object_id, date, c, d, e, f 
FROM <table_name> 
ORDER BY date desc ENABLE (RETURN_TOP 2)

ORDER BY will do the work. For limiting number of returned rows use ENABLE (RETURN_TOP N)