Я вижу, что в одной из наших таблиц строка с последней отметкой времени имеет значения NULL в большинстве столбцов, за исключением последней строки с правильными значениями.Есть ли способ перенести эти значения из последней, кроме одной строки, в последнюю строку?
Я пытался найти решение с помощью комбинации логических / аналитических функций CASE, но не могу понять,Любые мысли приветствуются.
Токовый выход:
with t as
(
select '99WC2003' as pol_id, to_date( '1/23/2017','mm/dd/yyyy') as Eff_dt , NULL as industry , '-1' as Model from dual Union all
select '99WC2003' as pol_id, to_date('1/22/2017','mm/dd/yyyy') as Eff_dt , 'retail' as industry , '0.34' as Model from dual Union all
select '99WC2003' as pol_id, to_date('1/21/2017','mm/dd/yyyy') as Eff_dt , 'retail' as industry , '0.55' as Model from dual Union all
select '10XYZ02' as pol_id, to_date('1/12/2019','mm/dd/yyyy') as Eff_dt , NULL as industry , '0' as Model from dual Union all
select '10XYZ02' as pol_id, to_date('1/11/2019','mm/dd/yyyy') as Eff_dt , 'tech' as industry , '0.3' as Model from dual
)
select pol_id, Eff_dt, industry, model from t
Ожидаемый выход:
with t as
(
select '99WC2003' as pol_id, to_date('1/23/2017','mm/dd/yyyy') as Eff_dt , 'retail' as industry , '0.34' as Model from dual Union all
select '99WC2003' as pol_id, to_date('1/22/2017','mm/dd/yyyy') as Eff_dt , 'retail' as industry , '0.34' as Model from dual Union all
select '99WC2003' as pol_id, to_date('1/21/2017','mm/dd/yyyy') as Eff_dt , 'retail' as industry , '0.55' as Model from dual Union all
select '10XYZ02' as pol_id, to_date('1/12/2019','mm/dd/yyyy') as Eff_dt , 'tech' as industry , '0.3' as Model from dual Union all
select '10XYZ02' as pol_id, to_date('1/11/2019','mm/dd/yyyy') as Eff_dt ,'tech' as industry , '0.3' as Model from dual
)
select pol_id, Eff_dt, industry, model from t