Hy all, in a clinical information system I am trying to count for DISTINCT patients born in a specific period. The data is collected by subselects from different tables. The query is as follows:
select count( distinct patient_guid ) from t_visite V where $V_value AND patient_guid in ( select patient_guid from t_visite where guid in ( select visite_guid from t_demographie where gebdat < '".$age[0]."1231' AND ( gebdat > '".$age[1]."0101' OR gebdat = '".$age[1]."0101' ) ) AND patient_guid = V.patient_guid ) $V_value is: V.datum < '20030601' AND V.datum > '20030101' (a specific time where the patients to be counted must have visited the hospital). $age[0] is the lower date of the "age" that shall be requested. $age[1] is the upper date of the "age" that shall be requested. $age[0] and $age[1] are being calculated by subtraction from the actual year. The input then is: 0-90 0-19 20-29 30-39 40-49 50-59 60-90 0-90 would then mean that $age[0] is: 2003-0 = 2003 and $age[1] = 2003-19 = 1984 In another query I try to get the patients that have visited the hospital in the requested period (the first part of the given query). These two queries are both equal in their result when the input to the given query (with the ages) runs with 0-90 as input. However, if I split this query up in chunks (0-19 , 20-29 , 30-39 , ... ) and sum up the results of the chunks, the overall number is always one too high ( 0-90 = 92 , sum of chunks = 93 ). I am using PERL and the PERL-DB-interface SAP::DBTech::sapdb Does anyone know what's happening there or does anyone see a mistake in my procedure? Even the second possibility would be extremely helpfull for me. Regards and thanx in advance, Dominic -- Dominic Veit (Software Developer) Medical Center, University of Freiburg Dept. of Rheumatology and Clin. Immunology Hugstetterstr. 55 79106 Freiburg (Germany) Tel.: 0761 270 37 84 Pager: 0168 73 22 60 0 E-mail: [EMAIL PROTECTED] _______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general
