I am appealing to the T-SQL experts in this community for assistance with this query as you have provided excellent guidance in the past...
I need to calculate the total amount of time a client waits while staff search for an available hospital bed. Sometimes these searches can take a few minutes, sometimes a couple days.
Here is a sample of the data I'm trying to summarize (color added to aid in clarity):
Image may be NSFW.
Clik here to view.
A value of "New Search" in the Type_of_Search column means represents a new visit by the client in the reporting period, meaning that is a separate "search" with a separate Total Wait Time. For instance, client 307432 visited our facility twice in Dec 2023, meaning there were 2 separate bed searches for him; one that took 1334 mins (22 hrs 14 mins) and one that took 1860 mins (31 hrs).
I'm trying to figure out how to display the...