I have a table like this:
CUSTOMERS_ID DATE_SALES DIMENSION
MARIO1 20200201 NULL
MARIO1 20200113 Spain
MARIO2 20200131 NULL
MARIO3 20200101 France
MARIO3 20191231 Spain
and I need to order by CUSTOMERS_ID and DATE_SALES DESC fields. Then I want to group by CUSTOMERS_ID field and get first not null value of DIMENSION field. The output table would be:
CUSTOMERS_ID DIMENSION
MARIO1 Spain
MARIO2 NULL
MARIO3 France
Any ideas? I have tried COALESCE
functions, FIRST_VALUE
, and I have not the results I had expected.
Thanks in advance!