Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 514
Language: English
Group categories:
Computers > Software
More group info »
Recent pages and files
QUERY: Discharged patients with rendering provider    

This query delivers a list of discharged patients with rendering provider and discharge date. If the patient was seen by more than one provider, he or she will appear multiple times in the list:

 

SELECT DISTINCT pt.lastname, pt.firstname, pt.id, pr.provcode, pt.dischargedate
FROM providers pr
JOIN jcharges jc ON jc.providernum = pr.providernum
JOIN patients pt ON jc.ptnum = pt.ptnum
WHERE pt.dischargedate IS NOT NULL
ORDER BY pt.lastname, pt.firstname, pt.id, pr.provcode

 

To sort by provider, rather than patient name, just change the ORDER BY clause:

 

SELECT DISTINCT pt.lastname, pt.firstname, pt.id, pr.provcode, pt.dischargedate
FROM providers pr
JOIN jcharges jc ON jc.providernum = pr.providernum
JOIN patients pt ON jc.ptnum = pt.ptnum
WHERE pt.dischargedate IS NOT NULL
ORDER BY pr.provcode, pt.lastname, pt.firstname, pt.id

Version: 
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google