How do I create a table with count of instances of an id before an event date that is individual to that id?
Would something like this do?

with only_returned as
  (select cust_id, 
          min(order_date) min_order_date
   from your_table
   where returned = 1
   group by cust_id
  )
select r.cust_id, 
       count(b.order_id) returned_before,
       count(a.order_id) returned_after
from only_returned r 
  join your_table b on b.cust_id = r.cust_id
                   and b.order_date &lt; r.min_order_date
  join your_table a on a.cust_id = r.cust_id          
                   and a.order_date &gt; r.min_order_date;



ONLY_RETURNED CTE contains customers whose orders were returned; it also selects the first return order date
then, join only_returned with your_table, twice:


once for orders placed before minimum return order date (the b alias)
once for orders placed after minimum return order date (the a alias)