GPSPOW
asked on
SQL query to retrieve conditional field value
I have a table of data (attached) which is a list of VisitID's with restraint orderdate, RenewalDate ,StopDate and DischDate.
I compute the interval in hours from the previous renewal order until the new renewal date until there is a stop order for each VisitID.
Sometimes the StopDate is not input. What I want to do is show the interval from the last Renewal Date until the StopDate. If there is not a Stop Date, then the interval will be from the Last RenewalDate until the DischDate. If there is no DischDate then the interval is from the last RenewalDate until the Date & Time the query is processed.
How can I do this?
Thanks
Glen
Renewal-Stop.xlsx
I compute the interval in hours from the previous renewal order until the new renewal date until there is a stop order for each VisitID.
Sometimes the StopDate is not input. What I want to do is show the interval from the last Renewal Date until the StopDate. If there is not a Stop Date, then the interval will be from the Last RenewalDate until the DischDate. If there is no DischDate then the interval is from the last RenewalDate until the Date & Time the query is processed.
How can I do this?
Thanks
Glen
Renewal-Stop.xlsx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Glen