0 and sorry for late reply;.
0 i have create table as per your requirement.
check this one.
create table #temp2(empid int,status_id int,startdate date,enddate date)
insert into #temp2 values(227,1,'2015-1-23','2015-2-02')
insert into #temp2 values(227,2,'2015-2-2','2015-2-03')
insert into #temp2 values(227,3,'2015-2-2','2015-2-04')
select top 1 empid,status_id,startdate,enddate from #temp2 order by enddate desc
0 my table is like this
emp_Id status_Id startdate EndDate
227 1 2015-1-23 2015-2-02
227 2 2015-2-2 2015-2-03
227 3 2015-2-2 2015-2-04
i just want all three status must check this last status ,and put employee into that system.
0 create table tb (id int,job bit,leave bit,absent bit,todaydate date)
insert into tb values(3,0,0,1,getdate())
select * from tb
id job leave absent todaydate
1 1 0 0 2015-02-06
2 0 1 0 2015-02-06
3 0 0 1 2015-02-06
select * from tb where job=1 order by todaydate
id job leave absent todaydate
1 1 0 0 2015-02-06
0 Hi ,
I think in your table have a date column, you can find latest on records on the behalf of date.
like this type
select * from tablename order by DatecolumnName.