I have a function that counts how many times you've visited and if you have converted or not. What I'd like is for the dense_rank to re-start the count, if there has been a conversion:
SELECT
uid,
channel,
time,
conversion,
dense_rank() OVER (PARTITION BY uid ORDER BY time asc) as visit_order
FROM table
current table output:
this customer (uid
) had a conversion at visit 18 and now I would want the visit_order
count from dense_rank
to restart at 0 for the same customer until it hits the next conversion that is non-null.
See this (I do not like "try this" ):
DBFIDDLE
output: