My table and data as following,declare @tLogin table(idx int identity, myID varchar(100), loginDte datetime, dtVersion timestamp)insert into @tLogin(myID,loginDte) values('superadmin', '2012-01-01')insert into @tLogin(myID,loginDte) values('superadmin', '2012-01-01')insert into @tLogin(myID,loginDte) values('superadmin', '2012-01-07')insert into @tLogin(myID,loginDte) values('superadmin', '2012-01-09')
I need to get lastLoginDte, which is1. If exist 1 data for superadmin in the @tLogin, it'll will return no data for the lastLoginDte2. If exist 2 or more data for superadmin in the @tLogin, it'll will return the 2nd row for the lastLoginDteSo far, my query as following,select * from @tLogin where myID='superadmin'order by dtVersion DESC
need help