I have created a query with subqueries in order to calculate the crowding in an emergency department and how many patients are awaiting admission
I now want to order the query in such a way that I can see when the most patients are in the department or what the maximum number of patients awaiting beds is but when I try to do this in the design view via the "sort" row, it returns an error
This is my query so far
SELECT T1.Patient_ID, T1.ED_Number,T1.ARRIVAL_DATETIME,
(SELECT count(*) FROM [Attendances fin] as T2 WHERET1.ARRIVAL_DATETIME>T2.ARRIVAL_DATETIME ANDT1.ARRIVAL_DATETIME<T2.DEPART_DATETIME) AS Crowding,
(SELECT count(*) FROM[Attendances fin] as T2 WHERE T1.ARRIVAL_DATETIME>T2.DEC_ADMIT_DATETIME ANDT1.ARRIVAL_DATETIME<T2.DEPART_DATETIME) AS AwaitingAdmit
FROM [Attendances fin] AS T1;
Has anyone got any smart solutions as to how I can now do this?
Regards
Will