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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:36:53+00:00 2026-06-09T21:36:53+00:00

Hey There I’m trying to figure out the sql code for this: Assuming I

  • 0

Hey There I’m trying to figure out the sql code for this:

Assuming I have 4 columns:

ID  NAME  EMAIL
1   Mike  mike@mike.com
2   Bob   bob@bob.com
3   Chris
4   Matt

I want to select the last entry not null from email so in this instance it would be looking for bob@bob.com
I tried Coalesce but that seemed to give me values from the column, but not the LAST one entered. MAX I think is only used to ID’s. Any thoughts?

  • 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-09T21:36:55+00:00Added an answer on June 9, 2026 at 9:36 pm

    By joining against a subquery which returns only the MAX(ID). This isn’t necessary in MySQL, but many other RDBMS won’t permit you to include columns other than the aggregate if they are not also in a GROUP BY clause.

    SELECT yourtable.*
    FROM
      yourtable
      JOIN (SELECT MAX(ID) AS ID FROM yourtable WHERE EMAIL IS NOT NULL) maxid ON yourtable.ID = maxid.ID
    

    Note: In either case this only works reliably if your ID is an auto-incrementing column and you have not meddled with it by inserting rows where previous ids had been deleted.

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

Sidebar

Related Questions

hey there i have this code that should save a file from sql server
hey there guys and girls i have this code that saves json as a
Hey there, assuming I have the following code in a mex routine: mxArray *newPoint
hey there, I have a Navigation Menu and my code looks like this.. <ul
Hey there, I am trying to get my signout button to work. This is
Hey there, I have the following code: sVal = analogRead(potPin); // read the value
Hey there I am trying to learn SQL by trying to complete online questions
Hey there, I'm trying to make a site which have following: News, Products, About
Hey there, so far i have this, it toggles my footer down and up,
Hey there, this is turning out to really be a tricky one for me.

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.