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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ORDER BY & GROUP BY not working

Status
Not open for further replies.

Gigi0614

Programmer
Jun 20, 2004
25
0
0
US
Here's my query:

SELECT scheduledSurgery.anesthesia, scheduledSurgery.LOS, scheduledSurgery.suite, patientInfo.firstname, patientInfo.lastname, patientInfo.surgeon, patientInfo.coverdbyins, patientInfo.surgeon, scheduledSurgery.DOS, scheduledSurgery.TOS
FROM patientInfo INNER JOIN scheduledSurgery ON patientInfo.patientID=scheduledSurgery.patientID
GROUP BY patientInfo.surgeon, scheduledSurgery.DOS, scheduledSurgery.TOS
ORDER BY patientInfo.surgeon, scheduledSurgery.DOS, scheduledSurgery.TOS;



Access doesn't like it, and I dont' see what's wrong!!!
It says that I am trying to execute a query that doesnt inclue anethesia as part of the aggregate function.

ARGHHH!!! Please help!! I'm pulling my hair out.
 
Why are you using a GROUP BY clause as you don't use any aggragate function ?
Why are you selecting patientInfo.surgeon twice ?
What do you want to do ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Oh, OK... I guess aggregate functions are SUMs and things like that, huh??

I guess I do not need the GROUP BY then.

This is for a report. I want to break by on each unique Surgeon, and have infor for each one sorted by Date of Surgery & Time of Surgery.
 
I don't think you need to select Surgeon twice.
To break by on each unique Surgeon, even the ORDER BY clause isn't needed as the report enforces its own sort, depending of the grouping you've designed.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top