5
Answers

how to get list of latest record of all employee

Sajid Hussain

Sajid Hussain

9y
634
1
i have a table in which i am storing multiple record of same employee and there are multiple employees also,i want to get list last record of all employees,then base on their status divide it like on job empstatus_Id 1,absent empstatus_Id 2, leave empstatus_Id 3,i want to get list of all employees latest record.
Answers (5)
0
Joginder Banger

Joginder Banger

NA 10k 490.2k 9y
and sorry for late reply;.
0
Joginder Banger

Joginder Banger

NA 10k 490.2k 9y
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
Sajid Hussain

Sajid Hussain

NA 346 49.4k 9y
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
Joginder Banger

Joginder Banger

NA 10k 490.2k 9y
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
Joginder Banger

Joginder Banger

NA 10k 490.2k 9y
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.