Jerry Fahrni

Pharmacy Informatics and Technology

  • Home
  • About
RSS

Sum(1) ..how could something so simple be so frustrating

Posted on April 21, 2009 by Jerry Fahrni
No Comments

This time of year always comes with a lot of requests for medication usage data from the Pharmacy Clinical Coordinator.  This year has been no exception. The most recent request was for a report identifying all medications in the pharmacy drug master that were used less than ten times in 2008. Seemed simple enough. Right. 

Pulling the data via a query was simple enough, but I didn’t want to have to present each case and sum the results on the actual report. Took me a couple of days, and a little help to find this little beauty…Sum(1). That’s it. Counted each unique drug instance over the period identified in the query. In this case all instances of a medication used less than 10 times in 2008.

The SQL is below. Note the location of the red text.

SELECT dbo_DrugFormulary.RX_NUMBER, dbo_DrugFormulary.GENERICNAME, Sum(1) AS totaluse, dbo_DrugFormulary.STR, dbo_DrugFormulary.UNIT, dbo_DrugFormulary.BRANDNAME, dbo_DrugFormulary.VOLUME, dbo_DrugFormulary.VOLUME_UNIT
FROM dbo_DRUGUSAGE_ARCHIVE RIGHT JOIN dbo_DrugFormulary ON dbo_DRUGUSAGE_ARCHIVE.DRUG_CODE = dbo_DrugFormulary.RX_NUMBER
WHERE (((dbo_DRUGUSAGE_ARCHIVE.START_DATE) Like “*2008*” Or (dbo_DRUGUSAGE_ARCHIVE.START_DATE) Is Null) AND ((dbo_DRUGUSAGE_ARCHIVE.PTNAME) Not Like “*zzz*”))
GROUP BY dbo_DrugFormulary.RX_NUMBER, dbo_DrugFormulary.GENERICNAME, dbo_DrugFormulary.STR, dbo_DrugFormulary.UNIT, dbo_DrugFormulary.BRANDNAME, dbo_DrugFormulary.VOLUME, dbo_DrugFormulary.VOLUME_UNIT
HAVING (((dbo_DrugFormulary.RX_NUMBER) Not In (“99999″)) AND ((Sum(1))<10))
ORDER BY dbo_DrugFormulary.GENERICNAME;

Resuts:

Medication No Use Qry

  • Share post:
Categories: Database | Tags: access, Database, sql, UDA
Notice: This work is licensed under a BY-NC-SA. Permalink: Sum(1) ..how could something so simple be so frustrating
Batch Files to Increase Pharmacy Efficiency

  • Latest Tweets

    • Cool Pharmacy Tech – Real time volume detection in syringes dlvr.it/1bhHlV 1 hour ago
    • Pharmacy needs a new method for sharing non-clinical information dlvr.it/1bXgss 13 hours ago
    • @Hamstav Thanks for the link to the video. This is incredible stuff. Any additional information? 15 hours ago
    • This is incredible -- RT @Hamstav: Software vision and the need for visual marking on syringes. youtu.be/COK6Qxs3qSA 15 hours ago
    • RT @Mark_Hanson: Scalpel, forceps, bandage, Xbox...Xbox? Surgeon's ingenious hands-free hack makes for a Kinect'd OR! t.co/1QUUZZ ... 1 day ago
  • Recent Posts

    • Cool Pharmacy Tech – Real time volume detection in syringes
    • Pharmacy needs a new method for sharing non-clinical information
    • UpToDate now available for #Android
    • Evernote update for Android is awesome
    • Ideas, Vision, Innovation: Fantasy vs. Reality
  • Blogroll

    • Apple Core Labs
    • Archetypical
    • Infusion Nurse Blog
    • Pharmacy Technology Resources
    • Rob Fahrni
    • RxINFORMATICA
    • RxInformatics
    • The Cynical Pharmacist
    • The Medicine Guy
    • The Student Pharmacist
    • Unnatural Language Processing
  • Categories

    • Automation (42)
    • Barcoding (61)
    • Cloud Computing (25)
    • Cool Technology (106)
    • CPOE (3)
    • Database (8)
    • EMR (31)
    • Hardware (5)
    • iPhone (17)
    • Medication Safety (80)
    • Mobile Computing (100)
    • None of the above (2)
    • Pharmacy Informatics (109)
    • Pharmacy Practice (22)
    • RFID (7)
    • Siemens (13)
    • Tablet PCs (50)
    • Technology (62)
    • Therapeutics (28)
    • Top Posts/Searches (28)
    • Uncategorized (85)
    • Web 2.0 (14)
    • What'd I miss (62)
© Jerry Fahrni. Proudly Powered by WordPress | Nest Theme by YChong