title: Query Performace Problem
body: <p>Using Access 2003</p>
  
  <p>Query</p>
  
  <pre><code>SELECT t1.PERSONID       ,t1.CARDEVENTDATE
         ,MIN(t2.CARDEVENTTIME) AS Intime
         ,MAX(t3.CARDEVENTTIME) AS Outtime,
  Min(t3.Cardeventtime) as BreakOut,
  Max(t4.CardEventTime) as BreakIn 
  
  FROM ( ( (  SELECT PERSONID
                  , CARDEVENTDATE
                           FROM T_CARDEVENT ) as t1
   LEFT OUTER JOIN  (SELECT PERSONID
                                   ,CARDEVENTDATE,  FUNCTION
                                    , CARDEVENTTIME
                        FROM T_CARDEVENT  WHERE  (FUNCTION = 'A'))  as t2
   ON t1.PERSONID = t2.PERSONID 
             AND t1.CARDEVENTDATE = t2.CARDEVENTDATE)  LEFT OUTER JOIN  (SELECT PERSONID
                                   ,CARDEVENTDATE,  FUNCTION
                                    , CARDEVENTTIME
                        FROM T_CARDEVENT  WHERE  (FUNCTION = 'D'))  as t3
   ON t1.PERSONID = t3.PERSONID 
             AND t1.CARDEVENTDATE = t3.CARDEVENTDATE )  LEFT OUTER JOIN  (SELECT PERSONID
                                   ,CARDEVENTDATE,  FUNCTION
                                    , CARDEVENTTIME
                        FROM T_CARDEVENT  WHERE  (FUNCTION = 'B'))  as t4
   ON t1.PERSONID = t4.PERSONID 
             AND t1.CARDEVENTDATE = t4.CARDEVENTDATE )  LEFT OUTER JOIN  (SELECT PERSONID
                                   ,CARDEVENTDATE,  FUNCTION
                                    , CARDEVENTTIME
                        FROM T_CARDEVENT  WHERE  (FUNCTION = 'C'))  as t5
   ON t1.PERSONID = t5.PERSONID 
             AND t1.CARDEVENTDATE = t5.CARDEVENTDATE 
  
             GROUP BY t1.PERSONID, t1.CARDEVENTDATE 
  </code></pre>
  
  <p>When i run the above query,  it was taking too much time to view the result, so times it was displaying error message as "not enough temp space in a memory" </p>
  
  <p>There is any alternative way to make a query like this in access.</p>
  
  <p>Need query help</p>