Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 275231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:43:55+00:00 2026-05-12T00:43:55+00:00

Using MS Access 2003 My query. select a.personid, a.cardeventdate as newday, a.intime as intime,

  • 0

Using MS Access 2003

My query.

select a.personid, a.cardeventdate as newday, a.intime as intime,
    max(b.cardeventdate) as prevday, b.outtime as outtime 
from (
    select personid, cardeventdate, min(cardeventtime) as Intime, 
        max(cardeventtime) as outtime 
    from (
        SELECT T_PERSON.cardno, T_PERSON.NAME, T_TITLE.TITLENAME, 
            T_CARDEVENT.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  
        ORDER BY T_PERSON.TITLECODE) 
    group by personid, cardeventdate
    ) as a INNER JOIN (
    select personid, cardeventdate, min(cardeventtime) as Intime, 
        max(cardeventtime) as outtime 
    from (
        SELECT T_PERSON.cardno, T_PERSON.NAME, 
            T_TITLE.TITLENAME, T_CARDEVENT.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  
        ORDER BY T_PERSON.TITLECODE) 
    group by personid, cardeventdate) as b ON a.PERSONID = b.PERSONID 
AND a.CARDEVENTDATE > b.CARDEVENTDATE     
GROUP BY a.PERSONID, a.CARDEVENTDATE, a.intime, b.outtime

Form the above query, Output is

personid    newday      intime  prevday     outtime

127         20081112    073540  20081111    073024
127         20081113    073420  20081111    073024
127         20081113    073420  20081112    122737
127         20081117    073710  20081111    073024
127         20081117    073710  20081113    073420
127         20081117    073710  20081112    122737
1496        20080819    081935  20080818    110555
1496        20080903    064211  20080819    081935
1496        20080903    064211  20080818    110555
1496        20080904    124129  20080903    064254
1496        20080904    124129  20080819    081935
1496        20080904    124129  20080818    110555
1496        20080908    134345  20080903    064254
1496        20080908    134345  20080819    081935
1496        20080908    134345  20080818    110555
1496        20080908    134345  20080904    130936
1606        20080831    132538  20080824    102744
1696        20080825    143758  20080824    182058
1696        20080831    121407  20080825    153204
1696        20080831    121407  20080824    182058
1696        20080901    110704  20080831    121407
1696        20080901    110704  20080825    153204
1696        20080901    110704  20080824    182058
1696        20080902    103342  20080831    121407

so on…

Date is displaying again and again, So Date display only once

Expected Output

personid    newday    intime    prevday    outtime

127         20081112  073540    20081111   073024
127         20081113  073420    20081112   122737
127         20081117  073710    20081113   073024

so on…

So from the above query how can I make group by.

Query Help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:43:56+00:00Added an answer on May 12, 2026 at 12:43 am

    Put DISTINCT in your first select

    e.g.

    select distinct a.personid, a.cardeventdate as newday,...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Access 2003 Query SELECT t1.PERSONID ,t1.CARDEVENTDATE ,MIN(t2.CARDEVENTTIME) AS Intime ,MAX(t3.CARDEVENTTIME) AS Outtime, Min(t3.Cardeventtime)
Using Access 2003 Two Table, Tmp_cardevent1, tmp_cardevent3 Query SELECT AllPossibleCardEvents.PersonId, AllPossibleCardEvents.CardEventDate, Actual.Intime FROM ((SELECT
Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name
Using Access 2003 Database Table1 Intime Outtime WorkTime OverTime 08:00:00 19:00:00 09:00:00 02:00:00 09:00:00
Using Access 2003 Database Table EmpID Intime Outtime 001 090020 180000 002 060000 220000
I'm using Access 2003 and doing a make table query. The idea is, I
Using Access 2003 I want to get a table value from the two databases
Using Access 2003 Table PersonID TotalHours 111 12.23.34 111 23.32.23 111 14.32.23 222 00:23:32
This query is supposed to run with ms access 2003 using SQL. the function
Using Access 2003 Table1 Personid Date1 101 02-02-2008 102 02-02-2008 103 02-02-2008 101 03-02-2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.