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

  • Home
  • SEARCH
  • 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 4327372
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:31:44+00:00 2026-05-21T09:31:44+00:00

I have a table and I would like to get a row containing all

  • 0

I have a table and I would like to get a row containing all the latest non-null attributes for each column (without combining separate queries for each column, which doesn’t seem elegant to me).

Example:

A     B     C     Time
1     a     7     0
NULL  NULL  3     1
3     NULL  4     2
NULL  NULL  6     3

Result I seek:

A     B     C
3     a     6

As I said, I know how to select what I want for each column separately, but I was wondering if there’s a better way to do it. No need to tax the poor database if it isn’t needed.

  • 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-21T09:31:45+00:00Added an answer on May 21, 2026 at 9:31 am

    Probably a better way than this, but it’s Monday and I’m not quite conscious yet:

    select @a:=null, @b:=null, @c:=null;
    select A,B,C from (
        select @a:=coalesce(A,@a) as A, @b:=coalesce(B,@b) as B, @c:=coalesce(C,@) as C time
        from yourtable
        order by time asc
    ) as y order by time desc limit 1;
    

    Basically, iterate over each row in the database and build up the “latest” value as you go, then reverse the result set and select only the one with the highest time value

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

Sidebar

Related Questions

I have a table with a Date column, and I would like to do
I have a really long 3 column table. I would like to <table> <tr><td>Column1</td><td>Column2</td></tr>
I have a large database and would like to select table names that have
I have two tables A and B. I would like to delete all the
I have a table that was imported as all UPPER CASE and I would
I have a set of tables in Oracle and I would like to identify
When designing user table what would be the must have fields from the security/user
If I have a table field named 'description', what would be the SQL (using
How would one structure a table for an entity that can have a one
I have two HTML tables which would ideally be placed side by side on

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.