Using MS Access database
I want to display today record min (time) and previous day record max (time)
Table
PERSON ID CARDEVENTDATE CARDEVENTTIME
5008 20090805 080000
5008 20090805 140000
5008 20090809 180000
5008 20090809 220000
5008 20090813 090000
5008 20090813 200000
5008 20090818 110000
5008 20090818 232200
3405 20090805 080000
3405 20090805 180000
3405 20090809 070000
3405 20090809 230000
3010 20080806 090000
3010 20080806 230000
3010 20080810 100000
3010 20080810 160000
and so on...
From the above table I want to display Today min (time) and previous day max (time)
Previous day means not yesterday, previous cardeventtime for the particular person id.
Am using sub queries.
I am using below mentioned query.
"SELECT PERSONID, CARDEVENTDATE, MIN (CARDEVENTTIME) AS INTIME,
MAX (CARDEVENTTIME) AS OUTTIME FROM (SELECT T_PERSON.PERSONID,
T_CARDEVENT.CARDEVENTDATE, T_CARDEVENT.CARDEVENTTIME
FROM (T_TITLE INNER JOIN T_PERSON ON T_TITLE.TITLECODE = T_PERSON.TITLECODE)
INNER JOIN T_CARDEVENT ON T_PERSON.PERSONID = T_CARDEVENT.PERSONID
WHERE T_CARDEVENT.CARDEVENTDATE BETWEEN '" & sdate & "' AND '" & edate & "'
ORDER BY T_PERSON.TITLECODE) GROUP BY PERSONID, CARDEVENTDATE))"
But am not able to get previous day max (time). I want to get Today min (time) and previous day Max (time) for the particular person id.
Previous day means not yesterday, previous cardeventtime for the particular person id.
Expected Output.
PERSON ID CARDEVENTDATE MIN TIME CARDEVENTDATE MAX TIME
5008 20090818 110000 20090813 200000
5008 20090813 090000 20090809 220000
5008 20090809 180000 20090805 140000
3405 20090809 070000 20090805 180000
3010 20080810 100000 20080806 230000
and so on...
Need Query Help.