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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:00:07+00:00 2026-06-14T01:00:07+00:00

I have tables Member and Transaction . Table Member has 2 columns MemberID and

  • 0

I have tables Member and Transaction. Table Member has 2 columns MemberID and MemberName. Table Transaction has 3 columns, MemberID, TransactionDate, and MemberBalance.

The rows in the tables are as shown below:

Table Member:

MemberID           MemberName
=============================
1                  John
2                  Betty
3                  Lisa

Table Transaction:

MemberID        TransactionDate         MemberBalance
=====================================================
1               13-12-2012              200
2               12-12-2012              90
1               10-09-2012              300

I would like to query for MemberID, MemberName and MemberBalance where the TransactionDate is the latest (max) for each MemberID.

My query is like this:

SELECT 
    t.MemberID, m.MemberName , t.MemberBalance
FROM 
    Member AS m 
INNER JOIN 
    Transaction AS t ON m.MemberID = t.MemberID 
WHERE 
    t.TransactionDate IN (SELECT MAX(TransactionDate)
                          FROM Transaction 
                          GROUP BY MemberID)

This query returns:

MemberID           MemberName         MemberBalance
===================================================
1                  John               200
2                  Betty              90

My problem is, I want the query to return:

MemberID           MemberName         MemberBalance
===================================================
1                  John               200
2                  Betty              90
3                  Lisa               NULL

I want the member to be displayed even if its MemberID does not exist in the Transaction table.

How do I do this?

Thank you.

  • 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-14T01:00:09+00:00Added an answer on June 14, 2026 at 1:00 am

    You need to use LEFT JOIN. Also you had an error in your query because if two members had transactions at the same time you can get two rows for both the users.

    Try this

    SELECT t.MemberID, m.MemberName , t.MemberBalance
    FROM Member AS m 
        LEFT JOIN Transaction AS t ON m.MemberID = t.MemberID AND t.TransactionDate=
        ( 
            SELECT MAX(TransactionDate)
            FROM Transaction T2
            WHERE T2.MemberID=t.MemberID
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables: Member, Employer, and Location. Member has MemberID, EmployerID, and LocationID.
I have 2 tables: shares and pending_share_changes. The shares table has the following columns:
I have four tables: characters arena_team arena_table_member arena_team_stats. characters table has guid, name arena_team
I have two tables named MEMBER - columns id(primary key), name, email & TOPICS
I have two tables. One table is meant to serve as a transaction history
I have two tables. The first table is the member table MEMBER TABLE ID
I have several tables: table user: id firstname lastname 1 John Doe 2 Jane
We have two tables Family and Member, the relation between these two is Family
We have a partitioned view with 12 member tables. The partitioning column is a
I have such tables in my database like Customer , Member , Instructor ,

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.