आप एक वर्ष के भीतर पंक्तियों की गणना करके ऐसा कर सकते हैं। फिर पहले को छोड़कर सभी अपडेट करें:
with toupdate as (
select t.*, row_number() over (partition by [year] order by [date]) as seqnum
from t
)
update toupdate
set [year] = NULL
where seqnum > 1;
यदि आप इसे select
. के रूप में चाहते हैं कथन:
with ts as (
select t.*, row_number() over (partition by [year] order by [date]) as seqnum
from t
)
select [date],
(case when seqnum = 1 then [year] end) as [year]
from ts;