declare @salenumbers table (
insert into @salenumbers values
;with ranked as (
, row_number()over(partition by Year order by salesAmt desc) as rn
, sum(SalesAmt)over(partition by Year) as tot_year_sales
), recur_cte as (
select SalesPerson, SalesAmt, Year, rn, tot_year_sales, SalesAmt as accumSales
where rn = 1
select ranked.SalesPerson, ranked.SalesAmt, ranked.Year, ranked.rn, ranked.tot_year_sales
, cast(ranked.SalesAmt+recur_cte.accumSales as decimal(12,2)) as accumSales
inner join recur_cte on ranked.rn = recur_cte.rn+1 and ranked.year = recur_cte.year
where ranked.SalesAmt+recur_cte.accumSales <= ranked.tot_year_sales*0.2
Open in new window
Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.