Icon View Incident Report

Serious Serious
Reported By: Andrew Vaz
Reported On: 7/25/2000
For: Version 2.03 Build 1
# 614 SQL SELECT Sub-Selects Not Working Properly When Sub-Select Query Cannot Be Live

Using a sub-select query within a parent SQL SELECT query will not work properly if the sub-select cannot be opened live, such as if there is a DISTINCT or GROUP BY clause or joins in the sub-select.

SELECT 
Req.ReqNumReq ,  Atendim.IdAtend , Atendim.IdFilialAtn , Atendim.
AtnAno , Atendim.AtnDtAtend ,
 Atendim.IdConv ,  Medreq.IdMedReq , MedReq.IdMed , Req.IdReq , ReqFat.
IdPlano , Req.ReqDtReq             
 FROM Atendim  
   INNER JOIN Medreq ON  (Medreq.IdAtend = Atendim.IdAtend)  AND  
(Medreq.IdFilialAtn = Atendim.IdFilialAtn) AND  (Medreq.AtnAno = 
Atendim.AtnAno) 
   INNER JOIN Req  ON  (Req.IdAtend = Medreq.IdAtend) AND  (Req.
IdFilialAtn = Medreq.IdFilialAtn) AND  (Req.AtnAno = Medreq.AtnAno)  
AND  (Req.IdMedReq = Medreq.IdMedReq)
   INNER JOIN Reqfat  ON  (Reqfat.IdAtend = Req.IdAtend) AND  (Reqfat.
IdFilialAtn = Req.IdFilialAtn)  AND  (Reqfat.AtnAno = Req.AtnAno) AND 
 (Reqfat.IdMedReq = Req.IdMedReq) AND  (Reqfat.IdReq = Req.IdReq) 
   WHERE   (Atendim.AtnDtAtend >= '06/06/2000' ) 
   AND  (Atendim.AtnDtAtend <= '05/08/2000' ) 
   AND  (Atendim.AtnFFaltaCart = 0 ) 
   AND  (Atendim.AtnFOutros = 0 ) 
   AND  (Req.ReqTipo = 2 ) 
   AND  (Reqfat.RFtFFat = 0 ) 
   AND (  (Reqfat.IdPlano = 6 )  
      OR  (Reqfat.IdPlano = 7 )  
      OR  (Reqfat.IdPlano = 8 )  
      OR  (Reqfat.IdPlano = 9 )  
      OR  (Reqfat.IdPlano = 10 )  
      OR  (Reqfat.IdPlano = 239 )  )  
   AND  (Req.IdReq in (Select Distinct ItReq.IdReq 
      from  ItReq  
         INNER JOIN Ems  ON  (Itreq.IdEms = Ems.IdEms) 
         INNER JOIN Setor ON  (Ems.IdSetor = Setor.IdSetor) 
      Where (ItReq.ItrFFaturado = 1 ) ))



Resolution Resolution
Fixed Problem on 7/26/2000 in version 2.04 build 1
Image