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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:01:49+00:00 2026-05-26T05:01:49+00:00

Two simple tables Base table +——–+ |id|value| +——–+ | | | +——–+ Event table

  • 0

Two simple tables

Base table

+--------+
|id|value|
+--------+
|  |     |
+--------+

Event table (with a lot of data..)

+--------------+
|id|event| date|
+--------------+
|  |     |     |
+--------------+

Then I would like to have a list of all base.value with corresponding to their last events (including values without event entries)

+----------------+
|id|lastEvt|value|
+----------------+
|  |       |     |
+----------------+

This is a (working but) very slow attempt

SELECT *
  FROM  ( 
    SELECT base.id,
           event.event,
           base.value
      FROM base
           LEFT OUTER JOIN event
                        ON base.id = event.id
     ORDER BY event.date DESC
) 
AS res
 GROUP BY res.id;

I suspect there is a better/faster way of doing the query, but I don’t know how..

  • 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-26T05:01:50+00:00Added an answer on May 26, 2026 at 5:01 am
    SELECT b.id, b.value, e.event
        FROM base b
            LEFT JOIN (SELECT id, MAX(date) AS LastEventDate
                           FROM event
                           GROUP BY id) q
                INNER JOIN event e
                    ON q.id = e.id
                        AND q.LastEventDate = e.date
                ON b.id = q.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two simple tables in my database. A card table that contains Id,
I have a simple database with two tables. Users and Configurations. A user has
Suppose that two tables exist: users and groups . How does one provide simple
I've two tables: TableA and TableB, joined by TableA.TableA_Id->1..n<-TableB.TableA_Id. A simple PK-FK. I need
I want to make a table that simply has two integer columns to serve
I have two simple while loops in my program that I feel ought to
I need to be able to merge two (very simple) JavaScript objects at runtime.
Simple idea: I have two images that I want to merge, one is 500x500
I have a really simple class with two methods; One that will be called
Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have

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.