Mehboob Ali

Mehboob Ali

  • NA
  • 25
  • 3.1k

i want LastSeen and Location of distinct Names

Sep 4 2019 5:37 AM
Here is the Table
Id   Name    LastSeen                 Location
1    john       02/04/2017 14:48    xyz
2    Sid         02/04/2017 22:48    abc
3    Sid         03/04/2017 1:48      asd
 
and Desired results from Table
 
Id    Name    LastSeen                 Location
1     john       02/04/2017 14:48    xyz
3     Sid        03/04/2017 1:48      asd
 
Can Some one  help withe Query

Answers (3)

2
Amit Mohanty

Amit Mohanty

  • 15
  • 51.7k
  • 6m
Sep 4 2019 7:17 AM
Hey try this
  1. SELECT * FROM tblYourTable A WHERE A.ID = (SELECT MAX(ID) FROM tblYourTable B WHERE A.NAME = B.NAME) ORDER BY ID 
Accepted Answer
1
Mehboob Ali

Mehboob Ali

  • 0
  • 25
  • 3.1k
Sep 5 2019 4:54 AM
Thanks Amit Mohantty.
0
Rajanikant Hawaldar

Rajanikant Hawaldar

  • 32
  • 38.8k
  • 438.5k
Sep 4 2019 6:47 AM
Hi Mehboob, Refer below thread and try the similar https://stackoverflow.com/questions/16550703/sql-get-the-last-date-time-record