Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping dates 1

Status
Not open for further replies.

sbbrown9924

Technical User
Mar 7, 2003
80
US
I am going to be building a graph showing the distribution of wait times in an ER waiting room. The dataset for this graph will come from a query that will count how many patients waited in a given time interval (ie, 20 patients waited less than an hour, 30, 1-2 hours; 15 2-3 hours, etc). I am able to calculate the time interval between the time a patient signs in and the time they are assigned to a bed by using this query.

SELECT *, DateDiff('n',TriageTime, InRoomTime) AS WaitingRoomTime Where....

How would I group and count the number of patients in each time interval (0-1 hour, 1-2 hours, 2-3 hours....)?
 
Try
Code:
Select Partition (DateDiff('n',TriageTime, InRoomTime)/60,
                  0, 10, 1) As [Waiting Time Range],

       Count(*)      As [Patients]

From   MyTable

Group By 
  Partition (DateDiff('n',TriageTime, InRoomTime)/60,
                  0, 10, 1)

[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 
Golom;

This works great! Can you tell me what partition does? I can't find it in any reference material.
 
Check it out

[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top