select
max_col1,
t1.col1,
max_col2,
t2.col2
from (
select
max(if(col1 is null, 0, id)) max_col1,
max(if(col2 is null, 0, id)) max_col2
from test) last_values
join test t1 on t1.id = max_col1
join test t2 on t2.id = max_col2;
+==========+======+==========+========+
| max_col1 | col1 | max_col2 | col2 |
+==========+======+==========+========+
| 19 | logo | 23 | ulitsa |
+----------+------+----------+--------+
SELECT DISTINCT
FIRST_VALUE(column_1) OVER (ORDER BY column_1 IS NULL, id DESC) column_1,
FIRST_VALUE(column_2) OVER (ORDER BY column_2 IS NULL, id DESC) column_2
FROM test;
SELECT DISTINCT
FIRST_VALUE(column_1) OVER (ORDER BY column_1 = ' ', id DESC) column_1,
FIRST_VALUE(column_2) OVER (ORDER BY column_2 = ' ', id DESC) column_2
FROM test;