You can pivot your data using a combination of CASE and MAX:
select v2.station,
max(day1) as day1,
max(val_day1) as val_day1,
max(day2) as day2,
max(val_day2) as val_day2,
max(day3) as day3,
max(val_day3) as val_day3,
max(day4) as day4,
max(val_day4) as val_day4,
max(greatest(val_day1, val_day2, val_day3, val_day4)) as max_val
from (
select v1.*,
(case when v1.day = 1 then v1.valid else NULL end) as day1,
(case when v1.day = 1 then v1.value else NULL end) as val_day1,
(case when v1.day = 2 then v1.valid else NULL end) as day2,
(case when v1.day = 2 then v1.value else NULL end) as val_day2,
(case when v1.day = 3 then v1.valid else NULL end) as day3,
(case when v1.day = 3 then v1.value else NULL end) as val_day3,
(case when v1.day = 4 then v1.valid else NULL end) as day4,
(case when v1.day = 4 then v1.value else NULL end) as val_day4
from
(select t.valid, t.station, t.value, t.valid - t.issue +1 as day
from so_data t) v1
) v2
group by v2.station
order by v2.station