PC Review


Reply
Thread Tools Rate Thread

Complex Count function with a condition

 
 
AlwaysLearing
Guest
Posts: n/a
 
      24th May 2010
Hello,
I have a table named, tbl_pt_records as shown below.

ID AdmitDate EndDate AdType Place Comments
NH
1*01 4/15/2009 4/27/2009 InitialAdmit Hospital Discharge to
Home ABC
1*01 5/1/2009 5/3/2009 Readmit Hospital Discharge to
Nursing ABC
1*01 5/3/2009 5/5/2009 InitialAdmit Nursing Still at
Nursing ABC
1*01 5/5/2009 5/15/2009 Readmit Hospital Discharge to Nursing
ABC
2*05 9/1/2009 9/5/2009 InitialAdmit Hospital Discharge to
Nursing ABC


I need to count all cases where AdType = "Readmit" with the condition
that person was admitted from the Nursing Home (line 4 is the correct
scenario where the person was in the NH from 5/3 - 5/5 and on 5/5 was
admitted to the Hospital). I want to exclude line 2 since the person
was discharge to Home and probably stayed home from 4/27 to 5/1.

From the above scenario, AdType ="Readmit would be equal to 1.

Is this possible to count? thanks!
 
Reply With Quote
 
 
 
 
KARL DEWEY
Guest
Posts: n/a
 
      24th May 2010
Try this --
SELECT Count(tbl_pt_records.ID) AS CountOfID
FROM tbl_pt_records INNER JOIN tbl_pt_records AS tbl_pt_records_1 ON
tbl_pt_records.ID = tbl_pt_records_1.ID
WHERE (((tbl_pt_records.AdmitDate)=[tbl_pt_records_1].[EndDate] Or
(tbl_pt_records.AdmitDate)=([tbl_pt_records_1].[EndDate])+1) AND
((tbl_pt_records.AdType)="Readmit") AND ((tbl_pt_records_1.Place)="Nursing")
AND ((tbl_pt_records.Place)="Hospital"));

--
Build a little, test a little.


"AlwaysLearing" wrote:

> Hello,
> I have a table named, tbl_pt_records as shown below.
>
> ID AdmitDate EndDate AdType Place Comments
> NH
> 1*01 4/15/2009 4/27/2009 InitialAdmit Hospital Discharge to
> Home ABC
> 1*01 5/1/2009 5/3/2009 Readmit Hospital Discharge to
> Nursing ABC
> 1*01 5/3/2009 5/5/2009 InitialAdmit Nursing Still at
> Nursing ABC
> 1*01 5/5/2009 5/15/2009 Readmit Hospital Discharge to Nursing
> ABC
> 2*05 9/1/2009 9/5/2009 InitialAdmit Hospital Discharge to
> Nursing ABC
>
>
> I need to count all cases where AdType = "Readmit" with the condition
> that person was admitted from the Nursing Home (line 4 is the correct
> scenario where the person was in the NH from 5/3 - 5/5 and on 5/5 was
> admitted to the Hospital). I want to exclude line 2 since the person
> was discharge to Home and probably stayed home from 4/27 to 5/1.
>
> From the above scenario, AdType ="Readmit would be equal to 1.
>
> Is this possible to count? thanks!
> .
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the count function with a condition in an Access Report =?Utf-8?B?a2FzaA==?= Microsoft Access 7 15th Apr 2010 08:24 AM
Count until condition is met and then retain final count Fats Microsoft Excel Misc 2 24th Dec 2009 01:21 AM
Complex Count farid2001 Microsoft Excel Programming 4 19th Sep 2008 10:48 PM
Complex Multi-condition, multi-workbook count =?Utf-8?B?SGVsaW9jcmFjeQ==?= Microsoft Excel Misc 0 4th Oct 2007 08:18 PM
complex count =?Utf-8?B?RlNtaXR0eQ==?= Microsoft Excel Worksheet Functions 7 3rd Feb 2006 10:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:14 PM.