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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:16:46+00:00 2026-05-27T17:16:46+00:00

So I am in the process of rewriting an MS Access application to a

  • 0

So I am in the process of rewriting an MS Access application to a SQL server backend. I am struggling with some unusual behavior in the way Access is using MAX() and how SQL Server is doing it. Maybe it is lack of sleep but I have been staring at this for hours and I can’t figure out why the SQL server results are different.

Sample Data:

Acct        ByUser  TranType    TranID      AddID   ClearTime               TranTime
12345678    CZ12           W    55545124    CZ36    12/12/2011 9:45:31 AM   12/12/2011 9:45:31 AM
12345678    CZ24           W    55545124    CZ36    12/12/2011 10:01:26 AM  12/12/2011 10:01:26 AM
12345678    CZ36           W    55545124    CZ36    12/12/2011 9:45:31 AM   12/12/2011 9:45:31 AM
12345678    MG12           W    55545124    CZ36    12/12/2011 10:48:43 AM  12/12/2011 10:48:43 AM
12345678    CZ25           W    55545124    CZ36    12/12/2011 9:45:31 AM   12/12/2011 9:45:31 AM

MS Access query:

SELECT Acct, TypeID, TranType
    , Max(TranTime) AS MaxOfTranTime
    , AddID
    , Max(ClearTime) AS MaxOfClearTime
FROM Cleared 
WHERE 
(
    ((ByUser) Like "CZ*" Or (ByUser) Like "TR*" Or 
    (ByUser) Like "RR*" Or (ByUser) Like "MG*" Or 
    (ByUser) Like "RN*" Or (ByUser) Like "PS*" Or 
    (ByUser) Like "OP*" Or (ByUser) Like "JA*" Or 
    (ByUser) Like "IC*" Or (ByUser) Like "IB*" Or 
    (ByUser) Like "FO*" Or (ByUser) Like "DV*" Or 
    (ByUser) Like "CD*" Or (ByUser) Like "BO*" Or 
    (ByUser) Like "2D*")
)
GROUP BY Acct, TypeID, TranType, AddID

Results in Access:

Account     TranID    TranType  MaxOfTranTime               AddID   MaxOfClearTime
12345678    55545124    W       12/12/2011  10:48:43 AM      CZ36   12/12/2011 9:45:31 AM

The query in SQL server is slightly different in that my ByUsers are stored in a table to minimize typing in tons of queries.

SELECT C.Acct
    , C.RequestId
    , C.TypeCode
    , Max(C.TranTime) as MaxTranTime
    , C.AddUserId
    , Max(C.ClearDate) As MaxClearDate
FROM Cleared C
WHERE EXISTS (SELECT *
                FROM UserIdFilter U
                WHERE ByUserId LIKE U.UserId) 
GROUP BY Acct, RequestId, TypeCode, AddUserId

The SQL Server results are:

Account     TranID    TranType  MaxOfTranTime          AddID    MaxOfClearTime
12345678    55545124    W      12/12/2011  10:48:43 AM  CZ36    12/12/2011  10:48:43 AM

When I go through this it seems to me that SQL server is correct in getting the MaxOfClearTime of 12/12/2011 10:48:43 AM but am I missing something? Does Access process MAX() differently? I feel like I am losing my mind with this so any other eyes on this would be great.

  • 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-27T17:16:47+00:00Added an answer on May 27, 2026 at 5:16 pm

    I put the data you provided in Access and ran the query, and it provided the output I’d expect i.e. 10 > 9.

    Of course I did assume that both ClearTime and TranTime are being stored as DateTime, If I change them to Text and alter the formatting to match your sample then I get the same results as you i.e. "9" > "10".

    Could you check the schema of the table in MS Access?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the process of rewriting an Access database and I have some
I am in the process of re-writing an MS Access database to SQL server
I am rewriting an Access application that uses a lot of Temp tables. Meaning
I'm using the MySQL .Net libraries in an older C# application I'm rewriting. The
We are in the process of rewriting some of our websites and trying to
I'm in the process of rewriting a web application (i.e. not web page, but
I am rewriting urls in my ASP.net application (not mvc) using a custom module.
I'm in the process of rewriting our application. We are building DataMappers to work
I am currently in the process of rewriting an application whereby teachers can plan
I'm in the process of rewriting a jQuery plugin to be used in an

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.