Verwenden Sie MIN()
als Fensterfunktion:
select t.*,
(case when col2 < add_months(min(col2) over (partition by col1), 3)
then col3
end) as imputed_col3
from t;
Hinweis:Wenn col2
kein Datum ist, können Sie es umwandeln:
select t.*,
(case when to_date(col2, 'YYYYMM') < add_months(min(to_date(col2, 'YYYYMM')) over (partition by col1), 3)
then col3
end) as imputed_col3
from t;