You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clancyjane edited this page Sep 23, 2014
·
1 revision
select distinct
CHILD
, removal_dt
, first_value(removal_dt)
over (partition by CHILD , year(removal_dt)
order by removal_dt asc) [first_removal_in_year]
, last_value(removal_dt) over
(partition by child
, year(removal_dt)
order by removal_dt asc
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
frombase.rptPlacement plc
where year(removal_dt) >=2000order by CHILD,removal_dt
in this example unbounded preceding works also
UNBOUNDED PRECEDING The range starts at the first row of the partition.
UNBOUNDED FOLLOWING The range ends at the last row of the partition.
CURRENT ROW range begins at the current row or ends at the current row
n PRECEDING or n FOLLOWING The range starts or ends n rows before or after the current row