angel7170
asked on
Oracle SQL query help
Hello,
I need help with writing query in Oracle SQL to get data from the next and previous row based on the conditions. I tried using LAG and LEAD functions but not getting the results as expected. I am attaching an excel file showing how the current setup of the data with the rules that needs to be applied. I have also included the expected result. Please help
Sample-Request.xls
I need help with writing query in Oracle SQL to get data from the next and previous row based on the conditions. I tried using LAG and LEAD functions but not getting the results as expected. I am attaching an excel file showing how the current setup of the data with the rules that needs to be applied. I have also included the expected result. Please help
Sample-Request.xls
ASKER
Sorry, I forgot to remove "REQUEST_BEGIN_TS" and "REQUEST_END_TS" column from the current setup. Those two columns I tried to create it by using LAG and LEAD functions but doesn't seem to work. So please ignore those columns
Yes, I need to populate the REQUEST_BEGIN_TS with the value in CREATED_TS. Thank you
Yes, I need to populate the REQUEST_BEGIN_TS with the value in CREATED_TS. Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome! Honestly, I spent 2 weeks on this one query but still with no luck. Thank you so much for the query as it is working as expected.
You guys are genius! Thank you
You guys are genius! Thank you
Does that mean we should ignore the value in the REQUEST_BEGIN_TS column?
In your example you have it populated with the value in CREATED_TS, but your comment implies we should use CREATED_TS instead and not actually use the already supplied REQUEST_BEGIN_TS.
Is that correct?