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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:36:47+00:00 2026-05-12T11:36:47+00:00

I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT

  • 0

I currently have a query similar to:

SELECT users.fname, users.lname, sales.date 
FROM users
LEFT JOIN sales ON users.id=sales.user

And this gives me the result of something like:

Fname | Lname | Date

Jeff  | K     | 2/12/08
Jeff  | K     | 5/18/08
Jeff  | K     | 2/22/09
Bill  | D     | 3/12/08
Bill  | D     | 12/9/08

This is what I pretty much expect since I have multiple sales linking to a user but I would like to have only one user listed (and maybe a way to pick which sales field that single result picks from) Is this possible and how would I go about doing this?

ie:

Fname | Lname | Date

Jeff  | K     | 5/18/08
Bill  | D     | 12/9/08
  • 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-12T11:36:47+00:00Added an answer on May 12, 2026 at 11:36 am
    SELECT users.fname, users.lname, MAX(sales.date)
    FROM users
    LEFT JOIN sales ON users.id=sales.user
    GROUP BY users.fname, users.lname
    

    or if you want more fields from the sales table:

    SELECT users.fname, users.lname, sales.date, sales.proft
    FROM users
    LEFT JOIN sales ON users.id=sales.user
    AND sales.date = (SELECT MAX(sales.date) FROM sales WHERE user = users.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
I currently have a bunch of SQLCHAR objects from a database query. The query
Dear all, I have a select query that currently produces the following results: DoctorName
I have a table in MySQL with text, date_posted, and user. I currently query
I currently have quite a messy query, which joins data from multiple tables involving
Okay, so I have this T-SQL statement: SELECT COUNT(DISTINCT RentalNo) as Count FROM RoomRental
I currently have a SQL query that returns a number of fields. I need
I currently have a list of things to update in the given mysqli query:
Hey guys I have a query that currently finds the latest comment for each
I have this query which works correctly in MySQL. More background on it here

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.