PostgreSQL - Select only newer value I have this table
CREATE TABLE public.element (
    id serial NOT NULL,
    elementname varchar(25) NOT NULL,
    element_sequence int4 NOT NULL,
    element_type varchar NOT NULL,
    creationdate timestamptz NOT NULL,
    validitystart date NOT NULL,
    validityend date NOT NULL,
);

What i need is to group by element_name and element_sequence and extract only the newer of every element.
So for example in a table like this
id|element_name|element_sequence|element_type|creationdate       |validityend|validitystar
--|------------|----------------|------------|-------------------|-----------|-------------|
 1|ab&gt;cd       |               1|simple      |2020-06-18 09:09:00| 2020-06-20|   2020-06-18|
 2|ab&gt;cd       |               1|simple      |2020-06-19 10:02:13| 2020-06-20|   2020-06-18|
 3|ab&gt;cd       |               2|composite   |2020-06-19 10:02:15| 2020-06-20|   2020-06-18|

only id 2 and 3 should be extracted because 1 and 2 have the same element_name and the same element_sequence but id 2 is newer
Real table have more column, but for this example i used only the main
maybe:
with latest as (
select element_name, element_sequence, max(creationdate) max_date from table group by element_name, element_sequence
)

select * --your column list
from table t
join latest lt on (lt.element_name = t.element_name and lt.element_sequence = t.element_sequence and lt.max_date = t.creationdate)

or
 select * from 
 (
 select element_name, element_sequence
, row_number() over (partition by element_name, element_sequence order by creationdate desc) lp -- you can add other columns
  from table 
  ) d
    where lp = 1