|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can I write a sql statement to do this?
OK here are my table fields in my access database. <br>ChildsSSN - text <br>ReportDate - Date <br>InsuranceType1 - True/False <br>InsuranceType2 - True/False <br>InsuranceType3 - True/False <br>InsuranceNone - True/False <br><br>It has to be done in an access query because the client just wants a database and no asp. Now this is what it has to do. I need to find the total amount of people that who on the first visit (lowest ReportDate) dont have insurance (InsuranceNone = true) and then within a timeperiod say 6 months get insurance (InsuranceType1, InsuranceType2 OR InsuranceType3 is true). <br><br>Please tell me there is a way I can do all of that inside of access. <br><br>Thanks for all of the help
|
|
#2
|
|||
|
|||
|
real quick, right off the top of my head - i didn't try this to make sure but how about something like:<br><br><div class="msgQuoteWrap"><div class="msgCode">select *<br>from whatevertable t<br>where reportdate = (select min(reportdate)<br> from whatevertable t1<br> where t1.childsSSN = t.childsSSN)<br>and insuranceNONE = true<br>and exists (select ChildsSSN<br> from whatevertable t2<br> where t2.childsSSN = t.childsSSN<br> and t2.reportdate > t.reportdate<br> and t2.reportdate < add_months(t.reportdate, 6)<br> and (insurancetype1 = true<br> or insurancetype2 = true<br> or insurancetype3 = true))</div></div>
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Can I write a sql statement to do this? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|