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

The Archive Base Latest Questions

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

I have a table name Data with fields Surmane , Name , Timestamp ,

  • 0

I have a table name Data with fields
Surmane, Name, Timestamp, PaidMoney, ChangAmmount, Address, Store

I want to have as result of a query the last record (DESC Timestamp Limit 1) of each person (group by Surname, Name) with the PaidMoney,ChangeAmmount, Address, Store

For example the result must be

Jones, Jim, 1290596796, 220.00, 0.25, 5th Avenue 120, Some Store1  
Kojak, Ian, 1290596890, 1000.00, 50.25, Derek Avenue 1020, Some Store2

For each combination of Surname, Name must present the last record.

I try to do this with:

select `Surname`, 
       `Name`, 
        max(date_format(from_unixtime(`Timestamp`),'%Y/%m/%d - %T')) AS `dateTime`,
       `PaidMoney`, 
       `ChangAmmount`, 
       `Address`, 
       `Store` 
from `Data` 
group by `Surname`, `Name`;

No good cause this doesn’t show correct data…..

Please Help…

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-05-21T06:44:48+00:00Added an answer on May 21, 2026 at 6:44 am
    select t1.surname,
           t1.name,
           from_unixtime(t1.timestamp,'%Y/%m/%d - %T') as datetime,
           t1.PaidMoney, 
           t1.ChangAmmount, 
           t1.Address, 
           t1.Store 
    from table as t1
    inner join (select concat_ws(' ',name,surname) as n,max(timestamp) as timestamp 
            from table
            group by name,surname) as t2
    on t1.timestamp = t2.timestamp and concat_ws(' ',t1.name,surname) = t2.n
    

    Your table contains redundant datas of names and surnames.
    It would be better if you put these datas in another table and refer to them using people id.
    Moreover without an id, the use of concat will slow down the join performance, even if you would have an index.

    edit.

    create view my_view as
    select * from table t1
    where timestamp = (select max(timestamp) from table as t2
                       where concat_ws(' ',t1.name,t1.surname) = concat_ws(' ',t2.name,t2.surname))     
    
    • 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 these fields: ID (Primary key) Name Some more data
Is it possible to have same table name on different schema with different data
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have a table emp with following structure and data: name dept salary -----
I have a table: ID name c_counts f_counts and I want to order all
I have a table with name varchar address varchar country varchar city varchar .....
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
I have inherited a table with a structure something like this: ID Name Timestamp
i have table AuditLog with fields including: audited_id | audited_type That results in data
My scenario is as follows: I have a table of data (handful of fields,

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.