简体   繁体   中英

Microsoft Access Query to SUM & SORT in a query

SELECT ptMeds.Station, ptMeds.TxDate, ptMeds.PaType, ptMeds.GenMedName, 
ptMeds.Strength, ptMeds.UnitsM, ptMeds.Volume, ptMeds.Dosage
FROM ptMeds
WHERE (((ptMeds.Station)="EMER1") AND ((ptMeds.PaType)="WITHDRAWN")) <I will need to look at the GenMedName field here also>
GROUP BY ptMeds.GenMedName;

I need to be able to SUM based on ptMeds.GenMedName and then sort the results highest to lowest. I've looked thru other responses to similar question but cannot find exactly what I need to do. Any help would be greatly appreciated.

SELECT ptMeds.Station, ptMeds.TxDate, ptMeds.PaType, ptMeds.GenMedName, 
ptMeds.Strength, ptMeds.UnitsM, ptMeds.Volume, ptMeds.Dosage
FROM ptMeds
WHERE (((ptMeds.Station)="EMER1") AND ((ptMeds.PaType)="WITHDRAWN")) 
GROUP BY ptMeds.GenMedName
ORDER BY ptMeds.GenMedName DESC;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM