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 8374035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:49:56+00:00 2026-06-09T14:49:56+00:00

i have the following code. my problem is i want to retrieve each employee

  • 0

i have the following code. my problem is i want to retrieve each employee name from another table name Employee which has a EmployeeID column similar to the AccessLog table, I used in this current query. now when i m joining these 2 table it is giving that weird error i said on the title. without the added code for joining- A.EmployeeID, Employee.FirstName in the first SELECT and ; AS A INNER JOIN Employee ON A.EmployeeID= Employee.EmployeeID to the last ORDER By clause, it is working good. I think problem is in the naming/alias. there are similar thread i saw, but those did not solve my problem. If someone could point me the fault, will appreciate.

SELECT **A.EmployeeID,
    Employee.FirstName,**
    MonthName(Month([LogDate])) AS MonthName,
    Round((Sum(Int(DateDiff("s",'00:00:00',Duration)))/3600)) AS TotalTime
    FROM (
         SELECT AccessLog.EmployeeID, 
                AccessLog.LogDate, 
                AccessLog.TerminalID, 
                AccessLog.LogTime, 
                Format((SELECT max(LogTime) 
                        FROM AccessLog AS Alias 
                        WHERE Alias.LogTime < AccessLog.LogTime 
                        AND Alias.EmployeeID = AccessLog.EmployeeID 
                        AND Alias.LogDate = AccessLog.LogDate 
                        AND (Alias.TerminalID)<>"iGuard1A" 
                        And (Alias.TerminalID)<>"iGuard1B"  
                        AND Alias.EmployeeID = AccessLog.EmployeeID),"hh:nn:ss") AS PrevTime, 
                Format((ElapsedTime(iif(PrevTime = '',logtime,prevtime),[LogTime])),"hh:nn:ss") AS Duration, 
                AccessLog.InOut 
             FROM AccessLog 
             WHERE (((AccessLog.TerminalID)<>"iGuard1A" 
             And (AccessLog.TerminalID)<>"iGuard1B") 
             AND ((AccessLog.EmployeeID) Like "2*") 
             AND ((AccessLog.InOut)="OUT")) 
             ORDER BY AccessLog.EmployeeID, AccessLog.LogDate, AccessLog.LogTime)  
             **AS A INNER JOIN Employee ON A.EmployeeID= Employee.EmployeeID**
      GROUP BY EmployeeID, MonthName(Month([LogDate]));
  • 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-06-09T14:49:58+00:00Added an answer on June 9, 2026 at 2:49 pm

    i solved it. As i said there is name/alias issue. I had to give seperate alias to the same table used in every subquery. even after that it show another error of aggragate function for the firstname in the top select, i also solved that by including it in a subquery. so in full my code goes as follows:

    SELECT C.EmployeeID, 
       (SELECT Employee.FirstName& ' ' &Employee.LastName 
          FROM Employee 
          where C.EmployeeID= Employee.EmployeeID) 
        AS FullName, 
       MonthName(Month([LogDate])) AS MonthName,
       Round((Sum(Int(DateDiff("s",'00:00:00',Duration)))/3600)) AS TotalTime
       FROM (SELECT B.EmployeeID, 
                  B.LogDate, 
                  B.TerminalID, 
                  B.LogTime, 
                  Format((SELECT max(LogTime) 
                          FROM AccessLog AS A 
                          WHERE A.LogTime < B.LogTime 
                          AND A.EmployeeID = B.EmployeeID  
                          AND A.LogDate = B.LogDate 
                          AND (A.TerminalID)<>"iGuard1A" 
                          And (A.TerminalID)<>"iGuard1B"  
                          AND A.EmployeeID = B.EmployeeID),"hh:nn:ss") AS PrevTime,  
                  Format((ElapsedTime(iif(PrevTime = '',logtime,prevtime),[LogTime])),"hh:nn:ss") AS Duration, 
                  B.InOut 
                  FROM AccessLog As B  
                  WHERE (((B.TerminalID)<>"iGuard1A" 
                   And (B.TerminalID)<>"iGuard1B") 
                   AND ((B.EmployeeID) Like "2*") 
                   AND ((B.InOut)="OUT")) 
                   ORDER BY B.EmployeeID, B.LogDate, B.LogTime)  
    AS C INNER JOIN Employee ON C.EmployeeID= Employee.EmployeeID
    GROUP BY C.EmployeeID, MonthName(Month([LogDate]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: The actual problem is the non-quoted code. I want
I have the following code I want to run, but the problem is $this->type
I have problems with following code: http://lisper.ru/apps/format/96 The problem is in normalize function, which
I have the following code to retrieve customer name, total (orders ), sum (order
I have a problem want to know answer, Why the following code will print
I have the following code, The problem is when I'm trying to assign the
So I have the following code, the problem is that it exits before all
I have the following code, and i have a problem regarding changing the ringtone
I have the following code, but i got a problem. Within my While, a
I have the following code: #include <iostream> #include Student.h <-- fixed the problem #include

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.