drew.allen - Friday, March 22, 2019 9:06 AM
Like the other post, the date selection range needs to be able to handle a dynamic date range...this date range will change, it is not going to remain the same and will vary by report and/or user entered values...is there a way to make the date range dynamic? (with the caveat it will skip over weekend and holidays and not include those---I can make a version of my calc age function that will return a date perhaps if it is not a weekend/holiday?)
Drew, this solution works when I make the following change(minus the static date range):
LEAD(o.Last_Updated_On, 1, COALESCE(r.Resolved_Date + 1, '9999-12-31')) OVER(PARTITION BY o.Case_ID ORDER BY o.Last_Updated_On) AS Update_Status_End_Dt
EDIT: I fixed the below issue---I created the temp tables prior to running the code using SELECT... INTO
(However, I am not sure what #Open_Cases o and #Resolved_Cases r refer to(is this a temp table)? If so, it was throwing an error...when I changed it to the Open_Cases and Resolved_Cases(the actual physical tables), it created duplicate rows in there(that somehow now can't be deleted??), which is not what I want... Any advice on what to do with that issue? )
Other than that it looks like the solution works properly...