plsql - How can I convert this SAS datastep to oracle sql for a conditional counter column? -


i apologize generalness of question. i'm trying create column groups rows based on time between current , previous observation. code below code i' wrote works correctly in sas. because of way data step runs vs how oracle sql runs can't figure out how in oracle sql. appreciated!

data group; set lag1; customer_key;  if (time_btw>5 or time_btw=.) journey=0; journey+1; if first.customer_key group=0; if journey=1 group+1; run; 

it looks defining groups based on time_btw. seem want analytic function. think code this:

select t.*,        sum(case when time_btw > 5 1 else 0 end) on (partition customer_key order ??) grp t; 

note in sql (unlike sas), tables represent unordered sets. means need column specifies ordering.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -