I Need Help With A Conditional Sql Window Function R Sql

I Need Help With A Conditional Sql Window Function R Sql