sbbrown9924
Technical User
I wrote this query that counts the number of patients seen per day in an ER:
SELECT DISTINCT Format(TriageTime,'mm/dd/yyyy') AS [fDate], COUNT(Format(TriageTime, 'mm/dd/yyyy')) AS [ctPatientsPerDay] FROM ARCHIVE GROUP BY Format(TriageTime,'mm/dd/yyyy')
that works ok. However, when I go to enter a date range...
SELECT DISTINCT Format(TriageTime,'mm/dd/yyyy') AS [fDate], COUNT(Format(TriageTime, 'mm/dd/yyyy')) AS [ctPatientsPerDay] FROM ARCHIVE WHERE TriageTime BETWEEN P_DateBegin AND P_DateEnd GROUP BY Format(TriageTime,'mm/dd/yyyy')
or even simply
SELECT DISTINCT Format(TriageTime,'mm/dd/yyyy') AS [fDate], COUNT(Format(TriageTime, 'mm/dd/yyyy')) AS [ctPatientsPerDay] FROM ARCHIVE WHERE TriageTime = #1/1/2006# GROUP BY Format(TriageTime,'mm/dd/yyyy')
I get the error message...
You tried to execute a query that does not include the specified expression 'Format(TriageTime,'mm/dd/yyyy')' as part of an aggregate function. I don't understand the message because that is the expression that is being aggregated.
BTW, even with the first query that works I can put in an ORDER BY clause that gets ignored no matter what field it sorts on.
Any ideas?
SELECT DISTINCT Format(TriageTime,'mm/dd/yyyy') AS [fDate], COUNT(Format(TriageTime, 'mm/dd/yyyy')) AS [ctPatientsPerDay] FROM ARCHIVE GROUP BY Format(TriageTime,'mm/dd/yyyy')
that works ok. However, when I go to enter a date range...
SELECT DISTINCT Format(TriageTime,'mm/dd/yyyy') AS [fDate], COUNT(Format(TriageTime, 'mm/dd/yyyy')) AS [ctPatientsPerDay] FROM ARCHIVE WHERE TriageTime BETWEEN P_DateBegin AND P_DateEnd GROUP BY Format(TriageTime,'mm/dd/yyyy')
or even simply
SELECT DISTINCT Format(TriageTime,'mm/dd/yyyy') AS [fDate], COUNT(Format(TriageTime, 'mm/dd/yyyy')) AS [ctPatientsPerDay] FROM ARCHIVE WHERE TriageTime = #1/1/2006# GROUP BY Format(TriageTime,'mm/dd/yyyy')
I get the error message...
You tried to execute a query that does not include the specified expression 'Format(TriageTime,'mm/dd/yyyy')' as part of an aggregate function. I don't understand the message because that is the expression that is being aggregated.
BTW, even with the first query that works I can put in an ORDER BY clause that gets ignored no matter what field it sorts on.
Any ideas?