Re: Need Help with Query

Need to be careful with data type:

select id,id1,

max(coalesce(key1,0))over(partition by id,id1 order by id,id1 rows between unbounded preceding and unbounded following) k1,max(coalesce(key2,0))over(partition by id,id1 order by id,id1 rows between unbounded preceding and unbounded following) k2,

max(coalesce(subkey1,0))over(partition by id,id1 order by id,id1 rows between unbounded preceding and unbounded following) sk1,

max(coalesce(subkey2,0))over(partition by id,id1 order by id,id1 rows between unbounded preceding and unbounded following) sk2

from yor_table qualify row_number() over(partition by id,id1 order by id,id1)=1